<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    
    <title>Python Types and C-Structures &mdash; NumPy v1.18 Manual</title>
    
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-extend.css">
    <link rel="stylesheet" href="../../_static/scipy.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" >
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.18.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <script type="text/javascript" src="../../_static/js/copybutton.js"></script>
    <link rel="author" title="About these documents" href="../../about.html" >
    <link rel="index" title="Index" href="../../genindex.html" >
    <link rel="search" title="Search" href="../../search.html" >
    <link rel="top" title="NumPy v1.18 Manual" href="../../index.html" >
    <link rel="up" title="NumPy C-API" href="index.html" >
    <link rel="next" title="System configuration" href="config.html" >
    <link rel="prev" title="NumPy C-API" href="index.html" > 
  </head>
  <body>
<div class="container">
  <div class="top-scipy-org-logo-header" style="background-color: #a2bae8;">
    <a href="../../index.html">
      <img border=0 alt="NumPy" src="../../_static/numpy_logo.png"></a>
    </div>
  </div>
</div>


    <div class="container">
      <div class="main">
        
	<div class="row-fluid">
	  <div class="span12">
	    <div class="spc-navbar">
              
    <ul class="nav nav-pills pull-left">
        <li class="active"><a href="https://numpy.org/">NumPy.org</a></li>
        <li class="active"><a href="https://numpy.org/doc">Docs</a></li>
        
        <li class="active"><a href="../../index.html">NumPy v1.18 Manual</a></li>
        

          <li class="active"><a href="../index.html" >NumPy Reference</a></li>
          <li class="active"><a href="index.html" accesskey="U">NumPy C-API</a></li> 
    </ul>
              
              
    <ul class="nav nav-pills pull-right">
      <li class="active">
        <a href="../../genindex.html" title="General Index"
           accesskey="I">index</a>
      </li>
      <li class="active">
        <a href="config.html" title="System configuration"
           accesskey="N">next</a>
      </li>
      <li class="active">
        <a href="index.html" title="NumPy C-API"
           accesskey="P">previous</a>
      </li>
    </ul>
              
	    </div>
	  </div>
	</div>
        

	<div class="row-fluid">
      <div class="spc-rightsidebar span3">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Python Types and C-Structures</a><ul>
<li><a class="reference internal" href="#new-python-types-defined">New Python Types Defined</a><ul>
<li><a class="reference internal" href="#pyarray-type-and-pyarrayobject">PyArray_Type and PyArrayObject</a></li>
<li><a class="reference internal" href="#pyarraydescr-type-and-pyarray-descr">PyArrayDescr_Type and PyArray_Descr</a></li>
<li><a class="reference internal" href="#pyufunc-type-and-pyufuncobject">PyUFunc_Type and PyUFuncObject</a></li>
<li><a class="reference internal" href="#pyarrayiter-type-and-pyarrayiterobject">PyArrayIter_Type and PyArrayIterObject</a></li>
<li><a class="reference internal" href="#pyarraymultiiter-type-and-pyarraymultiiterobject">PyArrayMultiIter_Type and PyArrayMultiIterObject</a></li>
<li><a class="reference internal" href="#pyarrayneighborhooditer-type-and-pyarrayneighborhooditerobject">PyArrayNeighborhoodIter_Type and PyArrayNeighborhoodIterObject</a></li>
<li><a class="reference internal" href="#pyarrayflags-type-and-pyarrayflagsobject">PyArrayFlags_Type and PyArrayFlagsObject</a></li>
<li><a class="reference internal" href="#scalararraytypes">ScalarArrayTypes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#other-c-structures">Other C-Structures</a><ul>
<li><a class="reference internal" href="#pyarray-dims">PyArray_Dims</a></li>
<li><a class="reference internal" href="#pyarray-chunk">PyArray_Chunk</a></li>
<li><a class="reference internal" href="#pyarrayinterface">PyArrayInterface</a></li>
<li><a class="reference internal" href="#internally-used-structures">Internally used structures</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">NumPy C-API</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="config.html"
                        title="next chapter">System configuration</a></p>
<div id="searchbox" style="display: none" role="search">
  <h4>Quick search</h4>
    <div>
    <form class="search" action="../../search.html" method="get">
      <input type="text" style="width: inherit;" name="q" />
      <input type="submit" value="search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
          <div class="span9">
            
        <div class="bodywrapper">
          <div class="body" id="spc-section-body">
            
  <div class="section" id="python-types-and-c-structures">
<h1>Python Types and C-Structures<a class="headerlink" href="#python-types-and-c-structures" title="Permalink to this headline">¶</a></h1>
<p>Several new types are defined in the C-code. Most of these are
accessible from Python, but a few are not exposed due to their limited
use. Every new Python type has an associated <a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span> <span class="pre">*</span></code></a> with an
internal structure that includes a pointer to a “method table” that
defines how the new object behaves in Python. When you receive a
Python object into C code, you always get a pointer to a
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> structure. Because a <a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> structure is
very generic and defines only <a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject_HEAD" title="(in Python v3.9)"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PyObject_HEAD</span></code></a>, by itself it
is not very interesting. However, different objects contain more
details after the <a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject_HEAD" title="(in Python v3.9)"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PyObject_HEAD</span></code></a> (but you have to cast to the
correct type to access them — or use accessor functions or macros).</p>
<div class="section" id="new-python-types-defined">
<h2>New Python Types Defined<a class="headerlink" href="#new-python-types-defined" title="Permalink to this headline">¶</a></h2>
<p>Python types are the functional equivalent in C of classes in Python.
By constructing a new Python type you make available a new object for
Python. The ndarray object is an example of a new type defined in C.
New types are defined in C by two basic steps:</p>
<ol class="arabic simple">
<li><p>creating a C-structure (usually named <code class="xref c c-type docutils literal notranslate"><span class="pre">Py{Name}Object</span></code>) that is
binary- compatible with the <a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> structure itself but holds
the additional information needed for that particular object;</p></li>
<li><p>populating the <a class="reference external" href="https://docs.python.org/dev/c-api/type.html#c.PyTypeObject" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyTypeObject</span></code></a> table (pointed to by the ob_type
member of the <a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> structure) with pointers to functions
that implement the desired behavior for the type.</p></li>
</ol>
<p>Instead of special method names which define behavior for Python
classes, there are “function tables” which point to functions that
implement the desired results. Since Python 2.2, the PyTypeObject
itself has become dynamic which allows C types that can be “sub-typed
“from other C-types in C, and sub-classed in Python. The children
types inherit the attributes and methods from their parent(s).</p>
<p>There are two major new types: the ndarray ( <a class="reference internal" href="#c.PyArray_Type" title="PyArray_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_Type</span></code></a> )
and the ufunc ( <a class="reference internal" href="#c.PyUFunc_Type" title="PyUFunc_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyUFunc_Type</span></code></a> ). Additional types play a
supportive role: the <a class="reference internal" href="#c.PyArrayIter_Type" title="PyArrayIter_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayIter_Type</span></code></a>, the
<a class="reference internal" href="#c.PyArrayMultiIter_Type" title="PyArrayMultiIter_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayMultiIter_Type</span></code></a>, and the <a class="reference internal" href="#c.PyArrayDescr_Type" title="PyArrayDescr_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayDescr_Type</span></code></a>
. The <a class="reference internal" href="#c.PyArrayIter_Type" title="PyArrayIter_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayIter_Type</span></code></a> is the type for a flat iterator for an
ndarray (the object that is returned when getting the flat
attribute). The <a class="reference internal" href="#c.PyArrayMultiIter_Type" title="PyArrayMultiIter_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayMultiIter_Type</span></code></a> is the type of the
object returned when calling <code class="docutils literal notranslate"><span class="pre">broadcast</span></code> (). It handles iteration
and broadcasting over a collection of nested sequences. Also, the
<a class="reference internal" href="#c.PyArrayDescr_Type" title="PyArrayDescr_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayDescr_Type</span></code></a> is the data-type-descriptor type whose
instances describe the data.  Finally, there are 21 new scalar-array
types which are new Python scalars corresponding to each of the
fundamental data types available for arrays. An additional 10 other
types are place holders that allow the array scalars to fit into a
hierarchy of actual Python types.</p>
<div class="section" id="pyarray-type-and-pyarrayobject">
<h3>PyArray_Type and PyArrayObject<a class="headerlink" href="#pyarray-type-and-pyarrayobject" title="Permalink to this headline">¶</a></h3>
<dl class="var">
<dt id="c.PyArray_Type">
<code class="sig-name descname">PyArray_Type</code><a class="headerlink" href="#c.PyArray_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>The Python type of the ndarray is <a class="reference internal" href="#c.PyArray_Type" title="PyArray_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_Type</span></code></a>. In C, every
ndarray is a pointer to a <a class="reference internal" href="#c.PyArrayObject" title="PyArrayObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayObject</span></code></a> structure. The ob_type
member of this structure contains a pointer to the <a class="reference internal" href="#c.PyArray_Type" title="PyArray_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_Type</span></code></a>
typeobject.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyArrayObject">
<code class="sig-name descname">PyArrayObject</code><a class="headerlink" href="#c.PyArrayObject" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#c.PyArrayObject" title="PyArrayObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayObject</span></code></a> C-structure contains all of the required
information for an array. All instances of an ndarray (and its
subclasses) will have this structure.  For future compatibility,
these structure members should normally be accessed using the
provided macros. If you need a shorter name, then you can make use
of <code class="xref c c-type docutils literal notranslate"><span class="pre">NPY_AO</span></code> (deprecated) which is defined to be equivalent to
<a class="reference internal" href="#c.PyArrayObject" title="PyArrayObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayObject</span></code></a>. Direct access to the struct fields are
deprecated. Use the <em class="xref py py-obj">PyArray_*(arr)</em> form instead.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">PyArrayObject</span> <span class="p">{</span>
    <span class="n">PyObject_HEAD</span>
    <span class="kt">char</span> <span class="o">*</span><span class="n">data</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">nd</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="o">*</span><span class="n">dimensions</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="o">*</span><span class="n">strides</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">base</span><span class="p">;</span>
    <span class="n">PyArray_Descr</span> <span class="o">*</span><span class="n">descr</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">flags</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">weakreflist</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArrayObject</span><span class="p">;</span>
</pre></div>
</div>
</dd></dl>

<dl class="macro">
<dt id="c.PyArrayObject.PyObject_HEAD">
<code class="sig-name descname">PyArrayObject.PyObject_HEAD</code><a class="headerlink" href="#c.PyArrayObject.PyObject_HEAD" title="Permalink to this definition">¶</a></dt>
<dd><p>This is needed by all Python objects. It consists of (at least)
a reference count member ( <code class="docutils literal notranslate"><span class="pre">ob_refcnt</span></code> ) and a pointer to the
typeobject ( <code class="docutils literal notranslate"><span class="pre">ob_type</span></code> ). (Other elements may also be present
if Python was compiled with special options see
Include/object.h in the Python source tree for more
information). The ob_type member points to a Python type
object.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.data">
char *<code class="sig-name descname">PyArrayObject.data</code><a class="headerlink" href="#c.PyArrayObject.data" title="Permalink to this definition">¶</a></dt>
<dd><p>Accessible via <a class="reference internal" href="array.html#c.PyArray_DATA" title="PyArray_DATA"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_DATA</span></code></a>, this data member is a
pointer to the first element of the array. This pointer can
(and normally should) be recast to the data type of the array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.nd">
int <code class="sig-name descname">PyArrayObject.nd</code><a class="headerlink" href="#c.PyArrayObject.nd" title="Permalink to this definition">¶</a></dt>
<dd><p>An integer providing the number of dimensions for this
array. When nd is 0, the array is sometimes called a rank-0
array. Such arrays have undefined dimensions and strides and
cannot be accessed. Macro <a class="reference internal" href="array.html#c.PyArray_NDIM" title="PyArray_NDIM"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_NDIM</span></code></a> defined in
<code class="docutils literal notranslate"><span class="pre">ndarraytypes.h</span></code> points to this data member. <a class="reference internal" href="array.html#c.NPY_MAXDIMS" title="NPY_MAXDIMS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_MAXDIMS</span></code></a>
is the largest number of dimensions for any array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.dimensions">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> <code class="sig-name descname">PyArrayObject.dimensions</code><a class="headerlink" href="#c.PyArrayObject.dimensions" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of integers providing the shape in each dimension as
long as nd <img class="math" src="../../_images/math/5029c2c60b99e78ec2ab8c273ff9aa8fdb7edac8.svg" alt="\geq"/> 1. The integer is always large enough
to hold a pointer on the platform, so the dimension size is
only limited by memory. <a class="reference internal" href="array.html#c.PyArray_DIMS" title="PyArray_DIMS"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_DIMS</span></code></a> is the macro
associated with this data member.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.strides">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayObject.strides</code><a class="headerlink" href="#c.PyArrayObject.strides" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of integers providing for each dimension the number of
bytes that must be skipped to get to the next element in that
dimension. Associated with macro <a class="reference internal" href="array.html#c.PyArray_STRIDES" title="PyArray_STRIDES"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_STRIDES</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.base">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArrayObject.base</code><a class="headerlink" href="#c.PyArrayObject.base" title="Permalink to this definition">¶</a></dt>
<dd><p>Pointed to by <a class="reference internal" href="array.html#c.PyArray_BASE" title="PyArray_BASE"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_BASE</span></code></a>, this member is used to hold a
pointer to another Python object that is related to this array.
There are two use cases:</p>
<ul class="simple">
<li><p>If this array does not own its own memory, then base points to the
Python object that owns it (perhaps another array object)</p></li>
<li><p>If this array has the (deprecated) <a class="reference internal" href="array.html#c.NPY_ARRAY_UPDATEIFCOPY" title="NPY_ARRAY_UPDATEIFCOPY"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_UPDATEIFCOPY</span></code></a> or
<a class="reference internal" href="array.html#c.NPY_ARRAY_WRITEBACKIFCOPY" title="NPY_ARRAY_WRITEBACKIFCOPY"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_WRITEBACKIFCOPY</span></code></a> flag set, then this array is a working
copy of a “misbehaved” array.</p></li>
</ul>
<p>When <code class="docutils literal notranslate"><span class="pre">PyArray_ResolveWritebackIfCopy</span></code> is called, the array pointed to
by base will be updated with the contents of this array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.descr">
<a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr">PyArray_Descr</a> *<code class="sig-name descname">PyArrayObject.descr</code><a class="headerlink" href="#c.PyArrayObject.descr" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a data-type descriptor object (see below). The
data-type descriptor object is an instance of a new built-in
type which allows a generic description of memory. There is a
descriptor structure for each data type supported. This
descriptor structure contains useful information about the type
as well as a pointer to a table of function pointers to
implement specific functionality. As the name suggests, it is
associated with the macro <a class="reference internal" href="array.html#c.PyArray_DESCR" title="PyArray_DESCR"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_DESCR</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.flags">
int <code class="sig-name descname">PyArrayObject.flags</code><a class="headerlink" href="#c.PyArrayObject.flags" title="Permalink to this definition">¶</a></dt>
<dd><p>Pointed to by the macro <a class="reference internal" href="array.html#c.PyArray_FLAGS" title="PyArray_FLAGS"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_FLAGS</span></code></a>, this data member represents
the flags indicating how the memory pointed to by data is to be
interpreted. Possible flags are <a class="reference internal" href="array.html#c.NPY_ARRAY_C_CONTIGUOUS" title="NPY_ARRAY_C_CONTIGUOUS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_C_CONTIGUOUS</span></code></a>,
<a class="reference internal" href="array.html#c.NPY_ARRAY_F_CONTIGUOUS" title="NPY_ARRAY_F_CONTIGUOUS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_F_CONTIGUOUS</span></code></a>, <a class="reference internal" href="array.html#c.NPY_ARRAY_OWNDATA" title="NPY_ARRAY_OWNDATA"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_OWNDATA</span></code></a>,
<a class="reference internal" href="array.html#c.NPY_ARRAY_ALIGNED" title="NPY_ARRAY_ALIGNED"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_ALIGNED</span></code></a>, <a class="reference internal" href="array.html#c.NPY_ARRAY_WRITEABLE" title="NPY_ARRAY_WRITEABLE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_WRITEABLE</span></code></a>,
<a class="reference internal" href="array.html#c.NPY_ARRAY_WRITEBACKIFCOPY" title="NPY_ARRAY_WRITEBACKIFCOPY"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_WRITEBACKIFCOPY</span></code></a>, and <a class="reference internal" href="array.html#c.NPY_ARRAY_UPDATEIFCOPY" title="NPY_ARRAY_UPDATEIFCOPY"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_UPDATEIFCOPY</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayObject.weakreflist">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArrayObject.weakreflist</code><a class="headerlink" href="#c.PyArrayObject.weakreflist" title="Permalink to this definition">¶</a></dt>
<dd><p>This member allows array objects to have weak references (using the
weakref module).</p>
</dd></dl>

</div>
<div class="section" id="pyarraydescr-type-and-pyarray-descr">
<h3>PyArrayDescr_Type and PyArray_Descr<a class="headerlink" href="#pyarraydescr-type-and-pyarray-descr" title="Permalink to this headline">¶</a></h3>
<dl class="var">
<dt id="c.PyArrayDescr_Type">
<code class="sig-name descname">PyArrayDescr_Type</code><a class="headerlink" href="#c.PyArrayDescr_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#c.PyArrayDescr_Type" title="PyArrayDescr_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayDescr_Type</span></code></a> is the built-in type of the
data-type-descriptor objects used to describe how the bytes comprising
the array are to be interpreted.  There are 21 statically-defined
<a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArray_Descr</span></code></a> objects for the built-in data-types. While these
participate in reference counting, their reference count should never
reach zero.  There is also a dynamic table of user-defined
<a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArray_Descr</span></code></a> objects that is also maintained. Once a
data-type-descriptor object is “registered” it should never be
deallocated either. The function <a class="reference internal" href="array.html#c.PyArray_DescrFromType" title="PyArray_DescrFromType"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_DescrFromType</span></code></a> (…) can
be used to retrieve a <a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArray_Descr</span></code></a> object from an enumerated
type-number (either built-in or user- defined).</p>
</dd></dl>

<dl class="type">
<dt id="c.PyArray_Descr">
<code class="sig-name descname">PyArray_Descr</code><a class="headerlink" href="#c.PyArray_Descr" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArray_Descr</span></code></a> structure lies at the heart of the
<a class="reference internal" href="#c.PyArrayDescr_Type" title="PyArrayDescr_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayDescr_Type</span></code></a>. While it is described here for
completeness, it should be considered internal to NumPy and manipulated via
<code class="docutils literal notranslate"><span class="pre">PyArrayDescr_*</span></code> or <code class="docutils literal notranslate"><span class="pre">PyDataType*</span></code> functions and macros. The size of this
structure is subject to change across versions of NumPy. To ensure
compatibility:</p>
<ul class="simple">
<li><p>Never declare a non-pointer instance of the struct</p></li>
<li><p>Never perform pointer arithmatic</p></li>
<li><p>Never use <code class="docutils literal notranslate"><span class="pre">sizof(PyArray_Descr)</span></code></p></li>
</ul>
<p>It has the following structure:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyObject_HEAD</span>
    <span class="n">PyTypeObject</span> <span class="o">*</span><span class="n">typeobj</span><span class="p">;</span>
    <span class="kt">char</span> <span class="n">kind</span><span class="p">;</span>
    <span class="kt">char</span> <span class="n">type</span><span class="p">;</span>
    <span class="kt">char</span> <span class="n">byteorder</span><span class="p">;</span>
    <span class="kt">char</span> <span class="n">flags</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">type_num</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">elsize</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">alignment</span><span class="p">;</span>
    <span class="n">PyArray_ArrayDescr</span> <span class="o">*</span><span class="n">subarray</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">fields</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">names</span><span class="p">;</span>
    <span class="n">PyArray_ArrFuncs</span> <span class="o">*</span><span class="n">f</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">metadata</span><span class="p">;</span>
    <span class="n">NpyAuxData</span> <span class="o">*</span><span class="n">c_metadata</span><span class="p">;</span>
    <span class="n">npy_hash_t</span> <span class="n">hash</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArray_Descr</span><span class="p">;</span>
</pre></div>
</div>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.typeobj">
<a class="reference external" href="https://docs.python.org/dev/c-api/type.html#c.PyTypeObject" title="(in Python v3.9)">PyTypeObject</a> *<code class="sig-name descname">PyArray_Descr.typeobj</code><a class="headerlink" href="#c.PyArray_Descr.typeobj" title="Permalink to this definition">¶</a></dt>
<dd><p>Pointer to a typeobject that is the corresponding Python type for
the elements of this array. For the builtin types, this points to
the corresponding array scalar. For user-defined types, this
should point to a user-defined typeobject. This typeobject can
either inherit from array scalars or not. If it does not inherit
from array scalars, then the <a class="reference internal" href="#c.NPY_USE_GETITEM" title="NPY_USE_GETITEM"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_USE_GETITEM</span></code></a> and
<a class="reference internal" href="#c.NPY_USE_SETITEM" title="NPY_USE_SETITEM"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_USE_SETITEM</span></code></a> flags should be set in the <code class="docutils literal notranslate"><span class="pre">flags</span></code> member.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.kind">
char <code class="sig-name descname">PyArray_Descr.kind</code><a class="headerlink" href="#c.PyArray_Descr.kind" title="Permalink to this definition">¶</a></dt>
<dd><p>A character code indicating the kind of array (using the array
interface typestring notation). A ‘b’ represents Boolean, a ‘i’
represents signed integer, a ‘u’ represents unsigned integer, ‘f’
represents floating point, ‘c’ represents complex floating point, ‘S’
represents 8-bit zero-terminated bytes, ‘U’ represents 32-bit/character
unicode string, and ‘V’ represents arbitrary.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.type">
char <code class="sig-name descname">PyArray_Descr.type</code><a class="headerlink" href="#c.PyArray_Descr.type" title="Permalink to this definition">¶</a></dt>
<dd><p>A traditional character code indicating the data type.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.byteorder">
char <code class="sig-name descname">PyArray_Descr.byteorder</code><a class="headerlink" href="#c.PyArray_Descr.byteorder" title="Permalink to this definition">¶</a></dt>
<dd><p>A character indicating the byte-order: ‘&gt;’ (big-endian), ‘&lt;’ (little-
endian), ‘=’ (native), ‘|’ (irrelevant, ignore). All builtin data-
types have byteorder ‘=’.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.flags">
char <code class="sig-name descname">PyArray_Descr.flags</code><a class="headerlink" href="#c.PyArray_Descr.flags" title="Permalink to this definition">¶</a></dt>
<dd><p>A data-type bit-flag that determines if the data-type exhibits object-
array like behavior. Each bit in this member is a flag which are named
as:</p>
<dl class="var">
<dt id="c.NPY_ITEM_REFCOUNT">
<code class="sig-name descname">NPY_ITEM_REFCOUNT</code><a class="headerlink" href="#c.NPY_ITEM_REFCOUNT" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates that items of this data-type must be reference
counted (using <a class="reference external" href="https://docs.python.org/dev/c-api/refcounting.html#c.Py_INCREF" title="(in Python v3.9)"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_INCREF</span></code></a> and <a class="reference external" href="https://docs.python.org/dev/c-api/refcounting.html#c.Py_DECREF" title="(in Python v3.9)"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DECREF</span></code></a> ).</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_ITEM_HASOBJECT">
<code class="sig-name descname">NPY_ITEM_HASOBJECT</code><a class="headerlink" href="#c.NPY_ITEM_HASOBJECT" title="Permalink to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#c.NPY_ITEM_REFCOUNT" title="NPY_ITEM_REFCOUNT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ITEM_REFCOUNT</span></code></a>.</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_LIST_PICKLE">
<code class="sig-name descname">NPY_LIST_PICKLE</code><a class="headerlink" href="#c.NPY_LIST_PICKLE" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates arrays of this data-type must be converted to a list
before pickling.</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_ITEM_IS_POINTER">
<code class="sig-name descname">NPY_ITEM_IS_POINTER</code><a class="headerlink" href="#c.NPY_ITEM_IS_POINTER" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates the item is a pointer to some other data-type</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_NEEDS_INIT">
<code class="sig-name descname">NPY_NEEDS_INIT</code><a class="headerlink" href="#c.NPY_NEEDS_INIT" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates memory for this data-type must be initialized (set
to 0) on creation.</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_NEEDS_PYAPI">
<code class="sig-name descname">NPY_NEEDS_PYAPI</code><a class="headerlink" href="#c.NPY_NEEDS_PYAPI" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates this data-type requires the Python C-API during
access (so don’t give up the GIL if array access is going to
be needed).</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_USE_GETITEM">
<code class="sig-name descname">NPY_USE_GETITEM</code><a class="headerlink" href="#c.NPY_USE_GETITEM" title="Permalink to this definition">¶</a></dt>
<dd><p>On array access use the <code class="docutils literal notranslate"><span class="pre">f-&gt;getitem</span></code> function pointer
instead of the standard conversion to an array scalar. Must
use if you don’t define an array scalar to go along with
the data-type.</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_USE_SETITEM">
<code class="sig-name descname">NPY_USE_SETITEM</code><a class="headerlink" href="#c.NPY_USE_SETITEM" title="Permalink to this definition">¶</a></dt>
<dd><p>When creating a 0-d array from an array scalar use
<code class="docutils literal notranslate"><span class="pre">f-&gt;setitem</span></code> instead of the standard copy from an array
scalar. Must use if you don’t define an array scalar to go
along with the data-type.</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_FROM_FIELDS">
<code class="sig-name descname">NPY_FROM_FIELDS</code><a class="headerlink" href="#c.NPY_FROM_FIELDS" title="Permalink to this definition">¶</a></dt>
<dd><p>The bits that are inherited for the parent data-type if these
bits are set in any field of the data-type. Currently (
<a class="reference internal" href="#c.NPY_NEEDS_INIT" title="NPY_NEEDS_INIT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_NEEDS_INIT</span></code></a> | <a class="reference internal" href="#c.NPY_LIST_PICKLE" title="NPY_LIST_PICKLE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_LIST_PICKLE</span></code></a> |
<a class="reference internal" href="#c.NPY_ITEM_REFCOUNT" title="NPY_ITEM_REFCOUNT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ITEM_REFCOUNT</span></code></a> | <a class="reference internal" href="#c.NPY_NEEDS_PYAPI" title="NPY_NEEDS_PYAPI"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_NEEDS_PYAPI</span></code></a> ).</p>
</dd></dl>

<dl class="var">
<dt id="c.NPY_OBJECT_DTYPE_FLAGS">
<code class="sig-name descname">NPY_OBJECT_DTYPE_FLAGS</code><a class="headerlink" href="#c.NPY_OBJECT_DTYPE_FLAGS" title="Permalink to this definition">¶</a></dt>
<dd><p>Bits set for the object data-type: ( <a class="reference internal" href="#c.NPY_LIST_PICKLE" title="NPY_LIST_PICKLE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_LIST_PICKLE</span></code></a>
| <a class="reference internal" href="#c.NPY_USE_GETITEM" title="NPY_USE_GETITEM"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_USE_GETITEM</span></code></a> | <a class="reference internal" href="#c.NPY_ITEM_IS_POINTER" title="NPY_ITEM_IS_POINTER"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ITEM_IS_POINTER</span></code></a> |
<code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_REFCOUNT</span></code> | <a class="reference internal" href="#c.NPY_NEEDS_INIT" title="NPY_NEEDS_INIT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_NEEDS_INIT</span></code></a> |
<a class="reference internal" href="#c.NPY_NEEDS_PYAPI" title="NPY_NEEDS_PYAPI"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_NEEDS_PYAPI</span></code></a>).</p>
</dd></dl>

<dl class="function">
<dt id="c.PyDataType_FLAGCHK">
<code class="sig-name descname">PyDataType_FLAGCHK</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr">PyArray_Descr</a><em> *dtype</em>, int<em> flags</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyDataType_FLAGCHK" title="Permalink to this definition">¶</a></dt>
<dd><p>Return true if all the given flags are set for the data-type
object.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyDataType_REFCHK">
<code class="sig-name descname">PyDataType_REFCHK</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr">PyArray_Descr</a><em> *dtype</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyDataType_REFCHK" title="Permalink to this definition">¶</a></dt>
<dd><p>Equivalent to <a class="reference internal" href="#c.PyDataType_FLAGCHK" title="PyDataType_FLAGCHK"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyDataType_FLAGCHK</span></code></a> (<em>dtype</em>,
<a class="reference internal" href="#c.NPY_ITEM_REFCOUNT" title="NPY_ITEM_REFCOUNT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ITEM_REFCOUNT</span></code></a>).</p>
</dd></dl>

</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.type_num">
int <code class="sig-name descname">PyArray_Descr.type_num</code><a class="headerlink" href="#c.PyArray_Descr.type_num" title="Permalink to this definition">¶</a></dt>
<dd><p>A number that uniquely identifies the data type. For new data-types,
this number is assigned when the data-type is registered.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.elsize">
int <code class="sig-name descname">PyArray_Descr.elsize</code><a class="headerlink" href="#c.PyArray_Descr.elsize" title="Permalink to this definition">¶</a></dt>
<dd><p>For data types that are always the same size (such as long), this
holds the size of the data type. For flexible data types where
different arrays can have a different elementsize, this should be
0.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.alignment">
int <code class="sig-name descname">PyArray_Descr.alignment</code><a class="headerlink" href="#c.PyArray_Descr.alignment" title="Permalink to this definition">¶</a></dt>
<dd><p>A number providing alignment information for this data type.
Specifically, it shows how far from the start of a 2-element
structure (whose first element is a <code class="docutils literal notranslate"><span class="pre">char</span></code> ), the compiler
places an item of this type: <code class="docutils literal notranslate"><span class="pre">offsetof(struct</span> <span class="pre">{char</span> <span class="pre">c;</span> <span class="pre">type</span> <span class="pre">v;},</span>
<span class="pre">v)</span></code></p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.subarray">
PyArray_ArrayDescr *<code class="sig-name descname">PyArray_Descr.subarray</code><a class="headerlink" href="#c.PyArray_Descr.subarray" title="Permalink to this definition">¶</a></dt>
<dd><p>If this is non- <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, then this data-type descriptor is a
C-style contiguous array of another data-type descriptor. In
other-words, each element that this descriptor describes is
actually an array of some other base descriptor. This is most
useful as the data-type descriptor for a field in another
data-type descriptor. The fields member should be <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if this
is non- <code class="docutils literal notranslate"><span class="pre">NULL</span></code> (the fields member of the base descriptor can be
non- <code class="docutils literal notranslate"><span class="pre">NULL</span></code> however). The <code class="xref c c-type docutils literal notranslate"><span class="pre">PyArray_ArrayDescr</span></code> structure is
defined using</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyArray_Descr</span> <span class="o">*</span><span class="n">base</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">shape</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArray_ArrayDescr</span><span class="p">;</span>
</pre></div>
</div>
<p>The elements of this structure are:</p>
<dl class="member">
<dt id="c.PyArray_ArrayDescr.base">
<a class="reference internal" href="#c.PyArray_Descr" title="PyArray_Descr">PyArray_Descr</a> *<code class="sig-name descname">PyArray_ArrayDescr.base</code><a class="headerlink" href="#c.PyArray_ArrayDescr.base" title="Permalink to this definition">¶</a></dt>
<dd><p>The data-type-descriptor object of the base-type.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrayDescr.shape">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArray_ArrayDescr.shape</code><a class="headerlink" href="#c.PyArray_ArrayDescr.shape" title="Permalink to this definition">¶</a></dt>
<dd><p>The shape (always C-style contiguous) of the sub-array as a Python
tuple.</p>
</dd></dl>

</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.fields">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArray_Descr.fields</code><a class="headerlink" href="#c.PyArray_Descr.fields" title="Permalink to this definition">¶</a></dt>
<dd><p>If this is non-NULL, then this data-type-descriptor has fields
described by a Python dictionary whose keys are names (and also
titles if given) and whose values are tuples that describe the
fields. Recall that a data-type-descriptor always describes a
fixed-length set of bytes. A field is a named sub-region of that
total, fixed-length collection. A field is described by a tuple
composed of another data- type-descriptor and a byte
offset. Optionally, the tuple may contain a title which is
normally a Python string. These tuples are placed in this
dictionary keyed by name (and also title if given).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.names">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArray_Descr.names</code><a class="headerlink" href="#c.PyArray_Descr.names" title="Permalink to this definition">¶</a></dt>
<dd><p>An ordered tuple of field names. It is NULL if no field is
defined.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.f">
<a class="reference internal" href="#c.PyArray_ArrFuncs" title="PyArray_ArrFuncs">PyArray_ArrFuncs</a> *<code class="sig-name descname">PyArray_Descr.f</code><a class="headerlink" href="#c.PyArray_Descr.f" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a structure containing functions that the type needs
to implement internal features. These functions are not the same
thing as the universal functions (ufuncs) described later. Their
signatures can vary arbitrarily.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.metadata">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArray_Descr.metadata</code><a class="headerlink" href="#c.PyArray_Descr.metadata" title="Permalink to this definition">¶</a></dt>
<dd><p>Metadata about this dtype.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.c_metadata">
<a class="reference internal" href="array.html#c.NpyAuxData" title="NpyAuxData">NpyAuxData</a> *<code class="sig-name descname">PyArray_Descr.c_metadata</code><a class="headerlink" href="#c.PyArray_Descr.c_metadata" title="Permalink to this definition">¶</a></dt>
<dd><p>Metadata specific to the C implementation
of the particular dtype. Added for NumPy 1.7.0.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Descr.hash">
Npy_hash_t *<code class="sig-name descname">PyArray_Descr.hash</code><a class="headerlink" href="#c.PyArray_Descr.hash" title="Permalink to this definition">¶</a></dt>
<dd><p>Currently unused. Reserved for future use in caching
hash values.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyArray_ArrFuncs">
<code class="sig-name descname">PyArray_ArrFuncs</code><a class="headerlink" href="#c.PyArray_ArrFuncs" title="Permalink to this definition">¶</a></dt>
<dd><p>Functions implementing internal features. Not all of these
function pointers must be defined for a given type. The required
members are <code class="docutils literal notranslate"><span class="pre">nonzero</span></code>, <code class="docutils literal notranslate"><span class="pre">copyswap</span></code>, <code class="docutils literal notranslate"><span class="pre">copyswapn</span></code>, <code class="docutils literal notranslate"><span class="pre">setitem</span></code>,
<code class="docutils literal notranslate"><span class="pre">getitem</span></code>, and <code class="docutils literal notranslate"><span class="pre">cast</span></code>. These are assumed to be non- <code class="docutils literal notranslate"><span class="pre">NULL</span></code>
and <code class="docutils literal notranslate"><span class="pre">NULL</span></code> entries will cause a program crash. The other
functions may be <code class="docutils literal notranslate"><span class="pre">NULL</span></code> which will just mean reduced
functionality for that data-type. (Also, the nonzero function will
be filled in with a default function if it is <code class="docutils literal notranslate"><span class="pre">NULL</span></code> when you
register a user-defined data-type).</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyArray_VectorUnaryFunc</span> <span class="o">*</span><span class="n">cast</span><span class="p">[</span><span class="n">NPY_NTYPES</span><span class="p">];</span>
    <span class="n">PyArray_GetItemFunc</span> <span class="o">*</span><span class="n">getitem</span><span class="p">;</span>
    <span class="n">PyArray_SetItemFunc</span> <span class="o">*</span><span class="n">setitem</span><span class="p">;</span>
    <span class="n">PyArray_CopySwapNFunc</span> <span class="o">*</span><span class="n">copyswapn</span><span class="p">;</span>
    <span class="n">PyArray_CopySwapFunc</span> <span class="o">*</span><span class="n">copyswap</span><span class="p">;</span>
    <span class="n">PyArray_CompareFunc</span> <span class="o">*</span><span class="n">compare</span><span class="p">;</span>
    <span class="n">PyArray_ArgFunc</span> <span class="o">*</span><span class="n">argmax</span><span class="p">;</span>
    <span class="n">PyArray_DotFunc</span> <span class="o">*</span><span class="n">dotfunc</span><span class="p">;</span>
    <span class="n">PyArray_ScanFunc</span> <span class="o">*</span><span class="n">scanfunc</span><span class="p">;</span>
    <span class="n">PyArray_FromStrFunc</span> <span class="o">*</span><span class="n">fromstr</span><span class="p">;</span>
    <span class="n">PyArray_NonzeroFunc</span> <span class="o">*</span><span class="n">nonzero</span><span class="p">;</span>
    <span class="n">PyArray_FillFunc</span> <span class="o">*</span><span class="n">fill</span><span class="p">;</span>
    <span class="n">PyArray_FillWithScalarFunc</span> <span class="o">*</span><span class="n">fillwithscalar</span><span class="p">;</span>
    <span class="n">PyArray_SortFunc</span> <span class="o">*</span><span class="n">sort</span><span class="p">[</span><span class="n">NPY_NSORTS</span><span class="p">];</span>
    <span class="n">PyArray_ArgSortFunc</span> <span class="o">*</span><span class="n">argsort</span><span class="p">[</span><span class="n">NPY_NSORTS</span><span class="p">];</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">castdict</span><span class="p">;</span>
    <span class="n">PyArray_ScalarKindFunc</span> <span class="o">*</span><span class="n">scalarkind</span><span class="p">;</span>
    <span class="kt">int</span> <span class="o">**</span><span class="n">cancastscalarkindto</span><span class="p">;</span>
    <span class="kt">int</span> <span class="o">*</span><span class="n">cancastto</span><span class="p">;</span>
    <span class="n">PyArray_FastClipFunc</span> <span class="o">*</span><span class="n">fastclip</span><span class="p">;</span>
    <span class="n">PyArray_FastPutmaskFunc</span> <span class="o">*</span><span class="n">fastputmask</span><span class="p">;</span>
    <span class="n">PyArray_FastTakeFunc</span> <span class="o">*</span><span class="n">fasttake</span><span class="p">;</span>
    <span class="n">PyArray_ArgFunc</span> <span class="o">*</span><span class="n">argmin</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArray_ArrFuncs</span><span class="p">;</span>
</pre></div>
</div>
<p>The concept of a behaved segment is used in the description of the
function pointers. A behaved segment is one that is aligned and in
native machine byte-order for the data-type. The <code class="docutils literal notranslate"><span class="pre">nonzero</span></code>,
<code class="docutils literal notranslate"><span class="pre">copyswap</span></code>, <code class="docutils literal notranslate"><span class="pre">copyswapn</span></code>, <code class="docutils literal notranslate"><span class="pre">getitem</span></code>, and <code class="docutils literal notranslate"><span class="pre">setitem</span></code>
functions can (and must) deal with mis-behaved arrays. The other
functions require behaved memory segments.</p>
<dl class="member">
<dt id="c.PyArray_ArrFuncs.cast">
void <code class="sig-name descname">cast</code><span class="sig-paren">(</span>void<em> *from</em>, void<em> *to</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n</em>, void<em> *fromarr</em>, void<em> *toarr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.cast" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of function pointers to cast from the current type to
all of the other builtin types. Each function casts a
contiguous, aligned, and notswapped buffer pointed at by
<em>from</em> to a contiguous, aligned, and notswapped buffer pointed
at by <em>to</em> The number of items to cast is given by <em>n</em>, and
the arguments <em>fromarr</em> and <em>toarr</em> are interpreted as
PyArrayObjects for flexible arrays to get itemsize
information.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.getitem">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">getitem</code><span class="sig-paren">(</span>void<em> *data</em>, void<em> *arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.getitem" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that returns a standard Python object
from a single element of the array object <em>arr</em> pointed to by
<em>data</em>. This function must be able to deal with “misbehaved
“(misaligned and/or swapped) arrays correctly.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.setitem">
int <code class="sig-name descname">setitem</code><span class="sig-paren">(</span><a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a><em> *item</em>, void<em> *data</em>, void<em> *arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.setitem" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that sets the Python object <em>item</em>
into the array, <em>arr</em>, at the position pointed to by <em>data</em>
. This function deals with “misbehaved” arrays. If successful,
a zero is returned, otherwise, a negative one is returned (and
a Python error set).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.copyswapn">
void <code class="sig-name descname">copyswapn</code><span class="sig-paren">(</span>void<em> *dest</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> dstride</em>, void<em> *src</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> sstride</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n</em>, int<em> swap</em>, void<em> *arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.copyswapn" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.copyswap">
void <code class="sig-name descname">copyswap</code><span class="sig-paren">(</span>void<em> *dest</em>, void<em> *src</em>, int<em> swap</em>, void<em> *arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.copyswap" title="Permalink to this definition">¶</a></dt>
<dd><p>These members are both pointers to functions to copy data from
<em>src</em> to <em>dest</em> and <em>swap</em> if indicated. The value of arr is
only used for flexible ( <a class="reference internal" href="dtype.html#c.NPY_STRING" title="NPY_STRING"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_STRING</span></code></a>, <a class="reference internal" href="dtype.html#c.NPY_UNICODE" title="NPY_UNICODE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_UNICODE</span></code></a>,
and <a class="reference internal" href="dtype.html#c.NPY_VOID" title="NPY_VOID"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_VOID</span></code></a> ) arrays (and is obtained from
<code class="docutils literal notranslate"><span class="pre">arr-&gt;descr-&gt;elsize</span></code> ). The second function copies a single
value, while the first loops over n values with the provided
strides. These functions can deal with misbehaved <em>src</em>
data. If <em>src</em> is NULL then no copy is performed. If <em>swap</em> is
0, then no byteswapping occurs. It is assumed that <em>dest</em> and
<em>src</em> do not overlap. If they overlap, then use <code class="docutils literal notranslate"><span class="pre">memmove</span></code>
(…) first followed by <code class="docutils literal notranslate"><span class="pre">copyswap(n)</span></code> with NULL valued
<code class="docutils literal notranslate"><span class="pre">src</span></code>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.compare">
int <code class="sig-name descname">compare</code><span class="sig-paren">(</span>const void*<em> d1</em>, const void*<em> d2</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.compare" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that compares two elements of the
array, <code class="docutils literal notranslate"><span class="pre">arr</span></code>, pointed to by <code class="docutils literal notranslate"><span class="pre">d1</span></code> and <code class="docutils literal notranslate"><span class="pre">d2</span></code>. This
function requires behaved (aligned and not swapped) arrays.
The return value is 1 if * <code class="docutils literal notranslate"><span class="pre">d1</span></code> &gt; * <code class="docutils literal notranslate"><span class="pre">d2</span></code>, 0 if * <code class="docutils literal notranslate"><span class="pre">d1</span></code> == *
<code class="docutils literal notranslate"><span class="pre">d2</span></code>, and -1 if * <code class="docutils literal notranslate"><span class="pre">d1</span></code> &lt; * <code class="docutils literal notranslate"><span class="pre">d2</span></code>. The array object <code class="docutils literal notranslate"><span class="pre">arr</span></code> is
used to retrieve itemsize and field information for flexible arrays.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.argmax">
int <code class="sig-name descname">argmax</code><span class="sig-paren">(</span>void*<em> data</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a>*<em> max_ind</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.argmax" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that retrieves the index of the
largest of <code class="docutils literal notranslate"><span class="pre">n</span></code> elements in <code class="docutils literal notranslate"><span class="pre">arr</span></code> beginning at the element
pointed to by <code class="docutils literal notranslate"><span class="pre">data</span></code>. This function requires that the
memory segment be contiguous and behaved. The return value is
always 0. The index of the largest element is returned in
<code class="docutils literal notranslate"><span class="pre">max_ind</span></code>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.dotfunc">
void <code class="sig-name descname">dotfunc</code><span class="sig-paren">(</span>void*<em> ip1</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> is1</em>, void*<em> ip2</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> is2</em>, void*<em> op</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.dotfunc" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that multiplies two <code class="docutils literal notranslate"><span class="pre">n</span></code> -length
sequences together, adds them, and places the result in
element pointed to by <code class="docutils literal notranslate"><span class="pre">op</span></code> of <code class="docutils literal notranslate"><span class="pre">arr</span></code>. The start of the two
sequences are pointed to by <code class="docutils literal notranslate"><span class="pre">ip1</span></code> and <code class="docutils literal notranslate"><span class="pre">ip2</span></code>. To get to
the next element in each sequence requires a jump of <code class="docutils literal notranslate"><span class="pre">is1</span></code>
and <code class="docutils literal notranslate"><span class="pre">is2</span></code> <em>bytes</em>, respectively. This function requires
behaved (though not necessarily contiguous) memory.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.scanfunc">
int <code class="sig-name descname">scanfunc</code><span class="sig-paren">(</span>FILE*<em> fd</em>, void*<em> ip</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.scanfunc" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that scans (scanf style) one element
of the corresponding type from the file descriptor <code class="docutils literal notranslate"><span class="pre">fd</span></code> into
the array memory pointed to by <code class="docutils literal notranslate"><span class="pre">ip</span></code>. The array is assumed
to be behaved.
The last argument <code class="docutils literal notranslate"><span class="pre">arr</span></code> is the array to be scanned into.
Returns number of receiving arguments successfully assigned (which
may be zero in case a matching failure occurred before the first
receiving argument was assigned), or EOF if input failure occurs
before the first receiving argument was assigned.
This function should be called without holding the Python GIL, and
has to grab it for error reporting.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.fromstr">
int <code class="sig-name descname">fromstr</code><span class="sig-paren">(</span>char*<em> str</em>, void*<em> ip</em>, char**<em> endptr</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.fromstr" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that converts the string pointed to by
<code class="docutils literal notranslate"><span class="pre">str</span></code> to one element of the corresponding type and places it
in the memory location pointed to by <code class="docutils literal notranslate"><span class="pre">ip</span></code>. After the
conversion is completed, <code class="docutils literal notranslate"><span class="pre">*endptr</span></code> points to the rest of the
string. The last argument <code class="docutils literal notranslate"><span class="pre">arr</span></code> is the array into which ip
points (needed for variable-size data- types). Returns 0 on
success or -1 on failure. Requires a behaved array.
This function should be called without holding the Python GIL, and
has to grab it for error reporting.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.nonzero">
Bool <code class="sig-name descname">nonzero</code><span class="sig-paren">(</span>void*<em> data</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.nonzero" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that returns TRUE if the item of
<code class="docutils literal notranslate"><span class="pre">arr</span></code> pointed to by <code class="docutils literal notranslate"><span class="pre">data</span></code> is nonzero. This function can
deal with misbehaved arrays.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.fill">
void <code class="sig-name descname">fill</code><span class="sig-paren">(</span>void*<em> data</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> length</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.fill" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that fills a contiguous array of given
length with data. The first two elements of the array must
already be filled- in. From these two values, a delta will be
computed and the values from item 3 to the end will be
computed by repeatedly adding this computed delta. The data
buffer must be well-behaved.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.fillwithscalar">
void <code class="sig-name descname">fillwithscalar</code><span class="sig-paren">(</span>void*<em> buffer</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> length</em>, void*<em> value</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.fillwithscalar" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that fills a contiguous <code class="docutils literal notranslate"><span class="pre">buffer</span></code> of
the given <code class="docutils literal notranslate"><span class="pre">length</span></code> with a single scalar <code class="docutils literal notranslate"><span class="pre">value</span></code> whose
address is given. The final argument is the array which is
needed to get the itemsize for variable-length arrays.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.sort">
int <code class="sig-name descname">sort</code><span class="sig-paren">(</span>void*<em> start</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> length</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.sort" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of function pointers to a particular sorting
algorithms. A particular sorting algorithm is obtained using a
key (so far <a class="reference internal" href="array.html#c.NPY_QUICKSORT" title="NPY_QUICKSORT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_QUICKSORT</span></code></a>, <a class="reference internal" href="array.html#c.NPY_HEAPSORT" title="NPY_HEAPSORT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_HEAPSORT</span></code></a>,
and <a class="reference internal" href="array.html#c.NPY_MERGESORT" title="NPY_MERGESORT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_MERGESORT</span></code></a> are defined). These sorts are done
in-place assuming contiguous and aligned data.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.argsort">
int <code class="sig-name descname">argsort</code><span class="sig-paren">(</span>void*<em> start</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a>*<em> result</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> length</em>, void<em> *arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.argsort" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of function pointers to sorting algorithms for this
data type. The same sorting algorithms as for sort are
available. The indices producing the sort are returned in
<code class="docutils literal notranslate"><span class="pre">result</span></code> (which must be initialized with indices 0 to
<code class="docutils literal notranslate"><span class="pre">length-1</span></code> inclusive).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.castdict">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">castdict</code><a class="headerlink" href="#c.PyArray_ArrFuncs.castdict" title="Permalink to this definition">¶</a></dt>
<dd><p>Either <code class="docutils literal notranslate"><span class="pre">NULL</span></code> or a dictionary containing low-level casting
functions for user- defined data-types. Each function is
wrapped in a <code class="xref c c-type docutils literal notranslate"><span class="pre">PyCObject</span> <span class="pre">*</span></code> and keyed by the data-type number.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.scalarkind">
<a class="reference internal" href="array.html#c.NPY_SCALARKIND" title="NPY_SCALARKIND">NPY_SCALARKIND</a> <code class="sig-name descname">scalarkind</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyArrayObject" title="PyArrayObject">PyArrayObject</a>*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.scalarkind" title="Permalink to this definition">¶</a></dt>
<dd><p>A function to determine how scalars of this type should be
interpreted. The argument is <code class="docutils literal notranslate"><span class="pre">NULL</span></code> or a 0-dimensional array
containing the data (if that is needed to determine the kind
of scalar). The return value must be of type
<a class="reference internal" href="array.html#c.NPY_SCALARKIND" title="NPY_SCALARKIND"><code class="xref c c-type docutils literal notranslate"><span class="pre">NPY_SCALARKIND</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.cancastscalarkindto">
int **<code class="sig-name descname">cancastscalarkindto</code><a class="headerlink" href="#c.PyArray_ArrFuncs.cancastscalarkindto" title="Permalink to this definition">¶</a></dt>
<dd><p>Either <code class="docutils literal notranslate"><span class="pre">NULL</span></code> or an array of <a class="reference internal" href="array.html#c.NPY_NSCALARKINDS" title="NPY_NSCALARKINDS"><code class="xref c c-type docutils literal notranslate"><span class="pre">NPY_NSCALARKINDS</span></code></a>
pointers. These pointers should each be either <code class="docutils literal notranslate"><span class="pre">NULL</span></code> or a
pointer to an array of integers (terminated by
<a class="reference internal" href="dtype.html#c.NPY_NOTYPE" title="NPY_NOTYPE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_NOTYPE</span></code></a>) indicating data-types that a scalar of
this data-type of the specified kind can be cast to safely
(this usually means without losing precision).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.cancastto">
int *<code class="sig-name descname">cancastto</code><a class="headerlink" href="#c.PyArray_ArrFuncs.cancastto" title="Permalink to this definition">¶</a></dt>
<dd><p>Either <code class="docutils literal notranslate"><span class="pre">NULL</span></code> or an array of integers (terminated by
<a class="reference internal" href="dtype.html#c.NPY_NOTYPE" title="NPY_NOTYPE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_NOTYPE</span></code></a> ) indicated data-types that this data-type
can be cast to safely (this usually means without losing
precision).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.fastclip">
void <code class="sig-name descname">fastclip</code><span class="sig-paren">(</span>void<em> *in</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n_in</em>, void<em> *min</em>, void<em> *max</em>, void<em> *out</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.fastclip" title="Permalink to this definition">¶</a></dt>
<dd><p>A function that reads <code class="docutils literal notranslate"><span class="pre">n_in</span></code> items from <code class="docutils literal notranslate"><span class="pre">in</span></code>, and writes to
<code class="docutils literal notranslate"><span class="pre">out</span></code> the read value if it is within the limits pointed to by
<code class="docutils literal notranslate"><span class="pre">min</span></code> and <code class="docutils literal notranslate"><span class="pre">max</span></code>, or the corresponding limit if outside. The
memory segments must be contiguous and behaved, and either
<code class="docutils literal notranslate"><span class="pre">min</span></code> or <code class="docutils literal notranslate"><span class="pre">max</span></code> may be <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, but not both.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.fastputmask">
void <code class="sig-name descname">fastputmask</code><span class="sig-paren">(</span>void<em> *in</em>, void<em> *mask</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n_in</em>, void<em> *values</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> nv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.fastputmask" title="Permalink to this definition">¶</a></dt>
<dd><p>A function that takes a pointer <code class="docutils literal notranslate"><span class="pre">in</span></code> to an array of <code class="docutils literal notranslate"><span class="pre">n_in</span></code>
items, a pointer <code class="docutils literal notranslate"><span class="pre">mask</span></code> to an array of <code class="docutils literal notranslate"><span class="pre">n_in</span></code> boolean
values, and a pointer <code class="docutils literal notranslate"><span class="pre">vals</span></code> to an array of <code class="docutils literal notranslate"><span class="pre">nv</span></code> items.
Items from <code class="docutils literal notranslate"><span class="pre">vals</span></code> are copied into <code class="docutils literal notranslate"><span class="pre">in</span></code> wherever the value
in <code class="docutils literal notranslate"><span class="pre">mask</span></code> is non-zero, tiling <code class="docutils literal notranslate"><span class="pre">vals</span></code> as needed if
<code class="docutils literal notranslate"><span class="pre">nv</span> <span class="pre">&lt;</span> <span class="pre">n_in</span></code>. All arrays must be contiguous and behaved.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.fasttake">
void <code class="sig-name descname">fasttake</code><span class="sig-paren">(</span>void<em> *dest</em>, void<em> *src</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> *indarray</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> nindarray</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n_outer</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> m_middle</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> nelem</em>, <a class="reference internal" href="array.html#c.NPY_CLIPMODE" title="NPY_CLIPMODE">NPY_CLIPMODE</a><em> clipmode</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.fasttake" title="Permalink to this definition">¶</a></dt>
<dd><p>A function that takes a pointer <code class="docutils literal notranslate"><span class="pre">src</span></code> to a C contiguous,
behaved segment, interpreted as a 3-dimensional array of shape
<code class="docutils literal notranslate"><span class="pre">(n_outer,</span> <span class="pre">nindarray,</span> <span class="pre">nelem)</span></code>, a pointer <code class="docutils literal notranslate"><span class="pre">indarray</span></code> to a
contiguous, behaved segment of <code class="docutils literal notranslate"><span class="pre">m_middle</span></code> integer indices,
and a pointer <code class="docutils literal notranslate"><span class="pre">dest</span></code> to a C contiguous, behaved segment,
interpreted as a 3-dimensional array of shape
<code class="docutils literal notranslate"><span class="pre">(n_outer,</span> <span class="pre">m_middle,</span> <span class="pre">nelem)</span></code>. The indices in <code class="docutils literal notranslate"><span class="pre">indarray</span></code> are
used to index <code class="docutils literal notranslate"><span class="pre">src</span></code> along the second dimension, and copy the
corresponding chunks of <code class="docutils literal notranslate"><span class="pre">nelem</span></code> items into <code class="docutils literal notranslate"><span class="pre">dest</span></code>.
<code class="docutils literal notranslate"><span class="pre">clipmode</span></code> (which can take on the values <a class="reference internal" href="array.html#c.NPY_RAISE" title="NPY_RAISE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_RAISE</span></code></a>,
<a class="reference internal" href="array.html#c.NPY_WRAP" title="NPY_WRAP"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_WRAP</span></code></a> or <a class="reference internal" href="array.html#c.NPY_CLIP" title="NPY_CLIP"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_CLIP</span></code></a>) determines how will
indices smaller than 0 or larger than <code class="docutils literal notranslate"><span class="pre">nindarray</span></code> will be
handled.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_ArrFuncs.argmin">
int <code class="sig-name descname">argmin</code><span class="sig-paren">(</span>void*<em> data</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a><em> n</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a>*<em> min_ind</em>, void*<em> arr</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyArray_ArrFuncs.argmin" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a function that retrieves the index of the
smallest of <code class="docutils literal notranslate"><span class="pre">n</span></code> elements in <code class="docutils literal notranslate"><span class="pre">arr</span></code> beginning at the element
pointed to by <code class="docutils literal notranslate"><span class="pre">data</span></code>. This function requires that the
memory segment be contiguous and behaved. The return value is
always 0. The index of the smallest element is returned in
<code class="docutils literal notranslate"><span class="pre">min_ind</span></code>.</p>
</dd></dl>

</dd></dl>

<p>The <a class="reference internal" href="#c.PyArray_Type" title="PyArray_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_Type</span></code></a> typeobject implements many of the features of
<a class="reference external" href="https://docs.python.org/dev/c-api/type.html#c.PyTypeObject" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">Python</span> <span class="pre">objects</span></code></a> including the <a class="reference external" href="https://docs.python.org/dev/c-api/typeobj.html#c.PyTypeObject.tp_as_number" title="(in Python v3.9)"><code class="xref c c-member docutils literal notranslate"><span class="pre">tp_as_number</span></code></a>, <a class="reference external" href="https://docs.python.org/dev/c-api/typeobj.html#c.PyTypeObject.tp_as_sequence" title="(in Python v3.9)"><code class="xref c c-member docutils literal notranslate"><span class="pre">tp_as_sequence</span></code></a>, <a class="reference external" href="https://docs.python.org/dev/c-api/typeobj.html#c.PyTypeObject.tp_as_mapping" title="(in Python v3.9)"><code class="xref c c-member docutils literal notranslate"><span class="pre">tp_as_mapping</span></code></a>, and <a class="reference external" href="https://docs.python.org/dev/c-api/typeobj.html#c.PyTypeObject.tp_as_buffer" title="(in Python v3.9)"><code class="xref c c-member docutils literal notranslate"><span class="pre">tp_as_buffer</span></code></a> interfaces. The <a class="reference external" href="https://docs.python.org/dev/c-api/typeobj.html#c.richcmpfunc" title="(in Python v3.9)"><code class="xref c c-type docutils literal notranslate"><span class="pre">rich</span> <span class="pre">comparison</span></code></a>) is also used along with new-style attribute lookup for
member (<a class="reference external" href="https://docs.python.org/dev/c-api/typeobj.html#c.PyTypeObject.tp_members" title="(in Python v3.9)"><code class="xref c c-member docutils literal notranslate"><span class="pre">tp_members</span></code></a>) and properties
(<a class="reference external" href="https://docs.python.org/dev/c-api/typeobj.html#c.PyTypeObject.tp_getset" title="(in Python v3.9)"><code class="xref c c-member docutils literal notranslate"><span class="pre">tp_getset</span></code></a>).
The <a class="reference internal" href="#c.PyArray_Type" title="PyArray_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArray_Type</span></code></a> can also be sub-typed.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>The <code class="docutils literal notranslate"><span class="pre">tp_as_number</span></code> methods use a generic approach to call whatever
function has been registered for handling the operation.  When the
<code class="docutils literal notranslate"><span class="pre">_multiarray_umath</span> <span class="pre">module</span></code> is imported, it sets the numeric operations
for all arrays to the corresponding ufuncs. This choice can be changed with
<a class="reference internal" href="ufunc.html#c.PyUFunc_ReplaceLoopBySignature" title="PyUFunc_ReplaceLoopBySignature"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUFunc_ReplaceLoopBySignature</span></code></a> The <code class="docutils literal notranslate"><span class="pre">tp_str</span></code> and <code class="docutils literal notranslate"><span class="pre">tp_repr</span></code>
methods can also be altered using <a class="reference internal" href="array.html#c.PyArray_SetStringFunction" title="PyArray_SetStringFunction"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_SetStringFunction</span></code></a>.</p>
</div>
</div>
<div class="section" id="pyufunc-type-and-pyufuncobject">
<h3>PyUFunc_Type and PyUFuncObject<a class="headerlink" href="#pyufunc-type-and-pyufuncobject" title="Permalink to this headline">¶</a></h3>
<dl class="var">
<dt id="c.PyUFunc_Type">
<code class="sig-name descname">PyUFunc_Type</code><a class="headerlink" href="#c.PyUFunc_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>The ufunc object is implemented by creation of the
<a class="reference internal" href="#c.PyUFunc_Type" title="PyUFunc_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyUFunc_Type</span></code></a>. It is a very simple type that implements only
basic getattribute behavior, printing behavior, and has call
behavior which allows these objects to act like functions. The
basic idea behind the ufunc is to hold a reference to fast
1-dimensional (vector) loops for each data type that supports the
operation. These one-dimensional loops all have the same signature
and are the key to creating a new ufunc. They are called by the
generic looping code as appropriate to implement the N-dimensional
function. There are also some generic 1-d loops defined for
floating and complexfloating arrays that allow you to define a
ufunc using a single scalar function (<em>e.g.</em> atanh).</p>
</dd></dl>

<dl class="type">
<dt id="c.PyUFuncObject">
<code class="sig-name descname">PyUFuncObject</code><a class="headerlink" href="#c.PyUFuncObject" title="Permalink to this definition">¶</a></dt>
<dd><p>The core of the ufunc is the <a class="reference internal" href="#c.PyUFuncObject" title="PyUFuncObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyUFuncObject</span></code></a> which contains all
the information needed to call the underlying C-code loops that
perform the actual work. While it is described here for completeness, it
should be considered internal to NumPy and manipulated via <code class="docutils literal notranslate"><span class="pre">PyUFunc_*</span></code>
functions. The size of this structure is subject to change across versions
of NumPy. To ensure compatibility:</p>
<ul class="simple">
<li><p>Never declare a non-pointer instance of the struct</p></li>
<li><p>Never perform pointer arithmetic</p></li>
<li><p>Never use <code class="docutils literal notranslate"><span class="pre">sizeof(PyUFuncObject)</span></code></p></li>
</ul>
<p>It has the following structure:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyObject_HEAD</span>
    <span class="kt">int</span> <span class="n">nin</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">nout</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">nargs</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">identity</span><span class="p">;</span>
    <span class="n">PyUFuncGenericFunction</span> <span class="o">*</span><span class="n">functions</span><span class="p">;</span>
    <span class="kt">void</span> <span class="o">**</span><span class="n">data</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">ntypes</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">reserved1</span><span class="p">;</span>
    <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">name</span><span class="p">;</span>
    <span class="kt">char</span> <span class="o">*</span><span class="n">types</span><span class="p">;</span>
    <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">doc</span><span class="p">;</span>
    <span class="kt">void</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">obj</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">userloops</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">core_enabled</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">core_num_dim_ix</span><span class="p">;</span>
    <span class="kt">int</span> <span class="o">*</span><span class="n">core_num_dims</span><span class="p">;</span>
    <span class="kt">int</span> <span class="o">*</span><span class="n">core_dim_ixs</span><span class="p">;</span>
    <span class="kt">int</span> <span class="o">*</span><span class="n">core_offsets</span><span class="p">;</span>
    <span class="kt">char</span> <span class="o">*</span><span class="n">core_signature</span><span class="p">;</span>
    <span class="n">PyUFunc_TypeResolutionFunc</span> <span class="o">*</span><span class="n">type_resolver</span><span class="p">;</span>
    <span class="n">PyUFunc_LegacyInnerLoopSelectionFunc</span> <span class="o">*</span><span class="n">legacy_inner_loop_selector</span><span class="p">;</span>
    <span class="n">PyUFunc_MaskedInnerLoopSelectionFunc</span> <span class="o">*</span><span class="n">masked_inner_loop_selector</span><span class="p">;</span>
    <span class="n">npy_uint32</span> <span class="o">*</span><span class="n">op_flags</span><span class="p">;</span>
    <span class="n">npy_uint32</span> <span class="o">*</span><span class="n">iter_flags</span><span class="p">;</span>
    <span class="cm">/* new in API version 0x0000000D */</span>
    <span class="n">npy_intp</span> <span class="o">*</span><span class="n">core_dim_sizes</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="o">*</span><span class="n">core_dim_flags</span><span class="p">;</span>

<span class="p">}</span> <span class="n">PyUFuncObject</span><span class="p">;</span>
</pre></div>
</div>
<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.nin">
int <code class="sig-name descname">PyUFuncObject.nin</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.nin" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of input arguments.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.nout">
int <code class="sig-name descname">PyUFuncObject.nout</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.nout" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of output arguments.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.nargs">
int <code class="sig-name descname">PyUFuncObject.nargs</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.nargs" title="Permalink to this definition">¶</a></dt>
<dd><p>The total number of arguments (<em>nin</em> + <em>nout</em>). This must be
less than <a class="reference internal" href="array.html#c.NPY_MAXARGS" title="NPY_MAXARGS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_MAXARGS</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.identity">
int <code class="sig-name descname">PyUFuncObject.identity</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.identity" title="Permalink to this definition">¶</a></dt>
<dd><p>Either <a class="reference internal" href="ufunc.html#c.PyUFunc_One" title="PyUFunc_One"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyUFunc_One</span></code></a>, <a class="reference internal" href="ufunc.html#c.PyUFunc_Zero" title="PyUFunc_Zero"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyUFunc_Zero</span></code></a>,
<a class="reference internal" href="ufunc.html#c.PyUFunc_None" title="PyUFunc_None"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyUFunc_None</span></code></a> or <code class="xref c c-data docutils literal notranslate"><span class="pre">PyUFunc_AllOnes</span></code> to indicate
the identity for this operation. It is only used for a
reduce-like call on an empty array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.functions">
void <code class="sig-name descname">PyUFuncObject.functions</code><span class="sig-paren">(</span>char**<em> args</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a>*<em> dims</em>, <a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a>*<em> steps</em>, void*<em> extradata</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.functions" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of function pointers — one for each data type
supported by the ufunc. This is the vector loop that is called
to implement the underlying function <em>dims</em> [0] times. The
first argument, <em>args</em>, is an array of <em>nargs</em> pointers to
behaved memory. Pointers to the data for the input arguments
are first, followed by the pointers to the data for the output
arguments. How many bytes must be skipped to get to the next
element in the sequence is specified by the corresponding entry
in the <em>steps</em> array. The last argument allows the loop to
receive extra information.  This is commonly used so that a
single, generic vector loop can be used for multiple
functions. In this case, the actual scalar function to call is
passed in as <em>extradata</em>. The size of this function pointer
array is ntypes.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.data">
void **<code class="sig-name descname">PyUFuncObject.data</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.data" title="Permalink to this definition">¶</a></dt>
<dd><p>Extra data to be passed to the 1-d vector loops or <code class="docutils literal notranslate"><span class="pre">NULL</span></code> if
no extra-data is needed. This C-array must be the same size (
<em>i.e.</em> ntypes) as the functions array. <code class="docutils literal notranslate"><span class="pre">NULL</span></code> is used if
extra_data is not needed. Several C-API calls for UFuncs are
just 1-d vector loops that make use of this extra data to
receive a pointer to the actual function to call.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.ntypes">
int <code class="sig-name descname">PyUFuncObject.ntypes</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.ntypes" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of supported data types for the ufunc. This number
specifies how many different 1-d loops (of the builtin data
types) are available.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.reserved1">
int <code class="sig-name descname">PyUFuncObject.reserved1</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.reserved1" title="Permalink to this definition">¶</a></dt>
<dd><p>Unused.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.name">
char *<code class="sig-name descname">PyUFuncObject.name</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.name" title="Permalink to this definition">¶</a></dt>
<dd><p>A string name for the ufunc. This is used dynamically to build
the __doc__ attribute of ufuncs.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.types">
char *<code class="sig-name descname">PyUFuncObject.types</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.types" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of <img class="math" src="../../_images/math/78d2cd5e9ca24646e8f01309188082e9eb4be0aa.svg" alt="nargs \times ntypes"/> 8-bit type_numbers
which contains the type signature for the function for each of
the supported (builtin) data types. For each of the <em>ntypes</em>
functions, the corresponding set of type numbers in this array
shows how the <em>args</em> argument should be interpreted in the 1-d
vector loop. These type numbers do not have to be the same type
and mixed-type ufuncs are supported.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.doc">
char *<code class="sig-name descname">PyUFuncObject.doc</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.doc" title="Permalink to this definition">¶</a></dt>
<dd><p>Documentation for the ufunc. Should not contain the function
signature as this is generated dynamically when __doc__ is
retrieved.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.ptr">
void *<code class="sig-name descname">PyUFuncObject.ptr</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.ptr" title="Permalink to this definition">¶</a></dt>
<dd><p>Any dynamically allocated memory. Currently, this is used for
dynamic ufuncs created from a python function to store room for
the types, data, and name members.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.obj">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyUFuncObject.obj</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.obj" title="Permalink to this definition">¶</a></dt>
<dd><p>For ufuncs dynamically created from python functions, this member
holds a reference to the underlying Python function.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.userloops">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyUFuncObject.userloops</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.userloops" title="Permalink to this definition">¶</a></dt>
<dd><p>A dictionary of user-defined 1-d vector loops (stored as CObject
ptrs) for user-defined types. A loop may be registered by the
user for any user-defined type. It is retrieved by type number.
User defined type numbers are always larger than
<a class="reference internal" href="dtype.html#c.NPY_USERDEF" title="NPY_USERDEF"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_USERDEF</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_enabled">
int <code class="sig-name descname">PyUFuncObject.core_enabled</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_enabled" title="Permalink to this definition">¶</a></dt>
<dd><p>0 for scalar ufuncs; 1 for generalized ufuncs</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_num_dim_ix">
int <code class="sig-name descname">PyUFuncObject.core_num_dim_ix</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_num_dim_ix" title="Permalink to this definition">¶</a></dt>
<dd><p>Number of distinct core dimension names in the signature</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_num_dims">
int *<code class="sig-name descname">PyUFuncObject.core_num_dims</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_num_dims" title="Permalink to this definition">¶</a></dt>
<dd><p>Number of core dimensions of each argument</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_dim_ixs">
int *<code class="sig-name descname">PyUFuncObject.core_dim_ixs</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_dim_ixs" title="Permalink to this definition">¶</a></dt>
<dd><p>Dimension indices in a flattened form; indices of argument <code class="docutils literal notranslate"><span class="pre">k</span></code> are
stored in <code class="docutils literal notranslate"><span class="pre">core_dim_ixs[core_offsets[k]</span> <span class="pre">:</span> <span class="pre">core_offsets[k]</span> <span class="pre">+</span>
<span class="pre">core_numdims[k]]</span></code></p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_offsets">
int *<code class="sig-name descname">PyUFuncObject.core_offsets</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_offsets" title="Permalink to this definition">¶</a></dt>
<dd><p>Position of 1st core dimension of each argument in <code class="docutils literal notranslate"><span class="pre">core_dim_ixs</span></code>,
equivalent to cumsum(<code class="docutils literal notranslate"><span class="pre">core_num_dims</span></code>)</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_signature">
char *<code class="sig-name descname">PyUFuncObject.core_signature</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_signature" title="Permalink to this definition">¶</a></dt>
<dd><p>Core signature string</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.type_resolver">
PyUFunc_TypeResolutionFunc *<code class="sig-name descname">PyUFuncObject.type_resolver</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.type_resolver" title="Permalink to this definition">¶</a></dt>
<dd><p>A function which resolves the types and fills an array with the dtypes
for the inputs and outputs</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.legacy_inner_loop_selector">
PyUFunc_LegacyInnerLoopSelectionFunc *<code class="sig-name descname">PyUFuncObject.legacy_inner_loop_selector</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.legacy_inner_loop_selector" title="Permalink to this definition">¶</a></dt>
<dd><p>A function which returns an inner loop. The <code class="docutils literal notranslate"><span class="pre">legacy</span></code> in the name arises
because for NumPy 1.6 a better variant had been planned. This variant
has not yet come about.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.reserved2">
void *<code class="sig-name descname">PyUFuncObject.reserved2</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.reserved2" title="Permalink to this definition">¶</a></dt>
<dd><p>For a possible future loop selector with a different signature.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.masked_inner_loop_selector">
PyUFunc_MaskedInnerLoopSelectionFunc *<code class="sig-name descname">PyUFuncObject.masked_inner_loop_selector</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.masked_inner_loop_selector" title="Permalink to this definition">¶</a></dt>
<dd><p>Function which returns a masked inner loop for the ufunc</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.op_flags">
<a class="reference internal" href="dtype.html#c.npy_uint32" title="npy_uint32">npy_uint32</a> <code class="sig-name descname">PyUFuncObject.op_flags</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.op_flags" title="Permalink to this definition">¶</a></dt>
<dd><p>Override the default operand flags for each ufunc operand.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.iter_flags">
<a class="reference internal" href="dtype.html#c.npy_uint32" title="npy_uint32">npy_uint32</a> <code class="sig-name descname">PyUFuncObject.iter_flags</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.iter_flags" title="Permalink to this definition">¶</a></dt>
<dd><p>Override the default nditer flags for the ufunc.</p>
</dd></dl>

<p>Added in API version 0x0000000D</p>
<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_dim_sizes">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyUFuncObject.core_dim_sizes</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_dim_sizes" title="Permalink to this definition">¶</a></dt>
<dd><p>For each distinct core dimension, the possible
<a class="reference internal" href="generalized-ufuncs.html#frozen"><span class="std std-ref">frozen</span></a> size if <code class="xref c c-data docutils literal notranslate"><span class="pre">UFUNC_CORE_DIM_SIZE_INFERRED</span></code> is 0</p>
</dd></dl>

<dl class="member">
<dt id="c.PyUFuncObject.PyUFuncObject.core_dim_flags">
<a class="reference internal" href="dtype.html#c.npy_uint32" title="npy_uint32">npy_uint32</a> *<code class="sig-name descname">PyUFuncObject.core_dim_flags</code><a class="headerlink" href="#c.PyUFuncObject.PyUFuncObject.core_dim_flags" title="Permalink to this definition">¶</a></dt>
<dd><p>For each distinct core dimension, a set of <code class="docutils literal notranslate"><span class="pre">UFUNC_CORE_DIM*</span></code> flags</p>
<ul class="simple">
<li><p><code class="xref c c-data docutils literal notranslate"><span class="pre">UFUNC_CORE_DIM_CAN_IGNORE</span></code> if the dim name ends in <code class="docutils literal notranslate"><span class="pre">?</span></code></p></li>
<li><p><code class="xref c c-data docutils literal notranslate"><span class="pre">UFUNC_CORE_DIM_SIZE_INFERRED</span></code> if the dim size will be
determined from the operands and not from a <a class="reference internal" href="generalized-ufuncs.html#frozen"><span class="std std-ref">frozen</span></a> signature</p></li>
</ul>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="pyarrayiter-type-and-pyarrayiterobject">
<h3>PyArrayIter_Type and PyArrayIterObject<a class="headerlink" href="#pyarrayiter-type-and-pyarrayiterobject" title="Permalink to this headline">¶</a></h3>
<dl class="var">
<dt id="c.PyArrayIter_Type">
<code class="sig-name descname">PyArrayIter_Type</code><a class="headerlink" href="#c.PyArrayIter_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>This is an iterator object that makes it easy to loop over an
N-dimensional array. It is the object returned from the flat
attribute of an ndarray. It is also used extensively throughout the
implementation internals to loop over an N-dimensional array. The
tp_as_mapping interface is implemented so that the iterator object
can be indexed (using 1-d indexing), and a few methods are
implemented through the tp_methods table. This object implements the
next method and can be used anywhere an iterator can be used in
Python.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyArrayIterObject">
<code class="sig-name descname">PyArrayIterObject</code><a class="headerlink" href="#c.PyArrayIterObject" title="Permalink to this definition">¶</a></dt>
<dd><p>The C-structure corresponding to an object of <a class="reference internal" href="#c.PyArrayIter_Type" title="PyArrayIter_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayIter_Type</span></code></a> is
the <a class="reference internal" href="#c.PyArrayIterObject" title="PyArrayIterObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayIterObject</span></code></a>. The <a class="reference internal" href="#c.PyArrayIterObject" title="PyArrayIterObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayIterObject</span></code></a> is used to
keep track of a pointer into an N-dimensional array. It contains associated
information used to quickly march through the array. The pointer can
be adjusted in three basic ways: 1) advance to the “next” position in
the array in a C-style contiguous fashion, 2) advance to an arbitrary
N-dimensional coordinate in the array, and 3) advance to an arbitrary
one-dimensional index into the array. The members of the
<a class="reference internal" href="#c.PyArrayIterObject" title="PyArrayIterObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayIterObject</span></code></a> structure are used in these
calculations. Iterator objects keep their own dimension and strides
information about an array. This can be adjusted as needed for
“broadcasting,” or to loop over only specific dimensions.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyObject_HEAD</span>
    <span class="kt">int</span>   <span class="n">nd_m1</span><span class="p">;</span>
    <span class="n">npy_intp</span>  <span class="n">index</span><span class="p">;</span>
    <span class="n">npy_intp</span>  <span class="n">size</span><span class="p">;</span>
    <span class="n">npy_intp</span>  <span class="n">coordinates</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_intp</span>  <span class="n">dims_m1</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_intp</span>  <span class="n">strides</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_intp</span>  <span class="n">backstrides</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_intp</span>  <span class="n">factors</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">PyArrayObject</span> <span class="o">*</span><span class="n">ao</span><span class="p">;</span>
    <span class="kt">char</span>  <span class="o">*</span><span class="n">dataptr</span><span class="p">;</span>
    <span class="n">Bool</span>  <span class="n">contiguous</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArrayIterObject</span><span class="p">;</span>
</pre></div>
</div>
<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.nd_m1">
int <code class="sig-name descname">PyArrayIterObject.nd_m1</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.nd_m1" title="Permalink to this definition">¶</a></dt>
<dd><p><img class="math" src="../../_images/math/f91e7f01955f0d20f5986c6d91696e7f446f669b.svg" alt="N-1"/> where <img class="math" src="../../_images/math/3bfb3a64189a14b2704f4610827762d5e3145114.svg" alt="N"/> is the number of dimensions in the
underlying array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.index">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> <code class="sig-name descname">PyArrayIterObject.index</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.index" title="Permalink to this definition">¶</a></dt>
<dd><p>The current 1-d index into the array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.size">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> <code class="sig-name descname">PyArrayIterObject.size</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.size" title="Permalink to this definition">¶</a></dt>
<dd><p>The total size of the underlying array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.coordinates">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayIterObject.coordinates</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.coordinates" title="Permalink to this definition">¶</a></dt>
<dd><p>An <img class="math" src="../../_images/math/3bfb3a64189a14b2704f4610827762d5e3145114.svg" alt="N"/> -dimensional index into the array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.dims_m1">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayIterObject.dims_m1</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.dims_m1" title="Permalink to this definition">¶</a></dt>
<dd><p>The size of the array minus 1 in each dimension.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.strides">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayIterObject.strides</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.strides" title="Permalink to this definition">¶</a></dt>
<dd><p>The strides of the array. How many bytes needed to jump to the next
element in each dimension.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.backstrides">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayIterObject.backstrides</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.backstrides" title="Permalink to this definition">¶</a></dt>
<dd><p>How many bytes needed to jump from the end of a dimension back
to its beginning. Note that <code class="docutils literal notranslate"><span class="pre">backstrides[k]</span> <span class="pre">==</span> <span class="pre">strides[k]</span> <span class="pre">*</span>
<span class="pre">dims_m1[k]</span></code>, but it is stored here as an optimization.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.factors">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayIterObject.factors</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.factors" title="Permalink to this definition">¶</a></dt>
<dd><p>This array is used in computing an N-d index from a 1-d index. It
contains needed products of the dimensions.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.ao">
<a class="reference internal" href="#c.PyArrayObject" title="PyArrayObject">PyArrayObject</a> *<code class="sig-name descname">PyArrayIterObject.ao</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.ao" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to the underlying ndarray this iterator was created to
represent.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.dataptr">
char *<code class="sig-name descname">PyArrayIterObject.dataptr</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.dataptr" title="Permalink to this definition">¶</a></dt>
<dd><p>This member points to an element in the ndarray indicated by the
index.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayIterObject.PyArrayIterObject.contiguous">
Bool <code class="sig-name descname">PyArrayIterObject.contiguous</code><a class="headerlink" href="#c.PyArrayIterObject.PyArrayIterObject.contiguous" title="Permalink to this definition">¶</a></dt>
<dd><p>This flag is true if the underlying array is
<a class="reference internal" href="array.html#c.NPY_ARRAY_C_CONTIGUOUS" title="NPY_ARRAY_C_CONTIGUOUS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_C_CONTIGUOUS</span></code></a>. It is used to simplify
calculations when possible.</p>
</dd></dl>

</dd></dl>

<p>How to use an array iterator on a C-level is explained more fully in
later sections. Typically, you do not need to concern yourself with
the internal structure of the iterator object, and merely interact
with it through the use of the macros <a class="reference internal" href="array.html#c.PyArray_ITER_NEXT" title="PyArray_ITER_NEXT"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_ITER_NEXT</span></code></a> (it),
<a class="reference internal" href="array.html#c.PyArray_ITER_GOTO" title="PyArray_ITER_GOTO"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_ITER_GOTO</span></code></a> (it, dest), or <a class="reference internal" href="array.html#c.PyArray_ITER_GOTO1D" title="PyArray_ITER_GOTO1D"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_ITER_GOTO1D</span></code></a>
(it, index). All of these macros require the argument <em>it</em> to be a
<a class="reference internal" href="#c.PyArrayIterObject" title="PyArrayIterObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayIterObject</span> <span class="pre">*</span></code></a>.</p>
</div>
<div class="section" id="pyarraymultiiter-type-and-pyarraymultiiterobject">
<h3>PyArrayMultiIter_Type and PyArrayMultiIterObject<a class="headerlink" href="#pyarraymultiiter-type-and-pyarraymultiiterobject" title="Permalink to this headline">¶</a></h3>
<dl class="var">
<dt id="c.PyArrayMultiIter_Type">
<code class="sig-name descname">PyArrayMultiIter_Type</code><a class="headerlink" href="#c.PyArrayMultiIter_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>This type provides an iterator that encapsulates the concept of
broadcasting. It allows <img class="math" src="../../_images/math/3bfb3a64189a14b2704f4610827762d5e3145114.svg" alt="N"/> arrays to be broadcast together
so that the loop progresses in C-style contiguous fashion over the
broadcasted array. The corresponding C-structure is the
<a class="reference internal" href="#c.PyArrayMultiIterObject" title="PyArrayMultiIterObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayMultiIterObject</span></code></a> whose memory layout must begin any
object, <em>obj</em>, passed in to the <a class="reference internal" href="array.html#c.PyArray_Broadcast" title="PyArray_Broadcast"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_Broadcast</span></code></a> (obj)
function. Broadcasting is performed by adjusting array iterators so
that each iterator represents the broadcasted shape and size, but
has its strides adjusted so that the correct element from the array
is used at each iteration.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyArrayMultiIterObject">
<code class="sig-name descname">PyArrayMultiIterObject</code><a class="headerlink" href="#c.PyArrayMultiIterObject" title="Permalink to this definition">¶</a></dt>
<dd><div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyObject_HEAD</span>
    <span class="kt">int</span> <span class="n">numiter</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">size</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">index</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">nd</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">dimensions</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">PyArrayIterObject</span> <span class="o">*</span><span class="n">iters</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
<span class="p">}</span> <span class="n">PyArrayMultiIterObject</span><span class="p">;</span>
</pre></div>
</div>
<dl class="member">
<dt id="c.PyArrayMultiIterObject.PyArrayMultiIterObject.numiter">
int <code class="sig-name descname">PyArrayMultiIterObject.numiter</code><a class="headerlink" href="#c.PyArrayMultiIterObject.PyArrayMultiIterObject.numiter" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of arrays that need to be broadcast to the same shape.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayMultiIterObject.PyArrayMultiIterObject.size">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> <code class="sig-name descname">PyArrayMultiIterObject.size</code><a class="headerlink" href="#c.PyArrayMultiIterObject.PyArrayMultiIterObject.size" title="Permalink to this definition">¶</a></dt>
<dd><p>The total broadcasted size.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayMultiIterObject.PyArrayMultiIterObject.index">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> <code class="sig-name descname">PyArrayMultiIterObject.index</code><a class="headerlink" href="#c.PyArrayMultiIterObject.PyArrayMultiIterObject.index" title="Permalink to this definition">¶</a></dt>
<dd><p>The current (1-d) index into the broadcasted result.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayMultiIterObject.PyArrayMultiIterObject.nd">
int <code class="sig-name descname">PyArrayMultiIterObject.nd</code><a class="headerlink" href="#c.PyArrayMultiIterObject.PyArrayMultiIterObject.nd" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of dimensions in the broadcasted result.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayMultiIterObject.PyArrayMultiIterObject.dimensions">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayMultiIterObject.dimensions</code><a class="headerlink" href="#c.PyArrayMultiIterObject.PyArrayMultiIterObject.dimensions" title="Permalink to this definition">¶</a></dt>
<dd><p>The shape of the broadcasted result (only <code class="docutils literal notranslate"><span class="pre">nd</span></code> slots are used).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayMultiIterObject.PyArrayMultiIterObject.iters">
<a class="reference internal" href="#c.PyArrayIterObject" title="PyArrayIterObject">PyArrayIterObject</a> **<code class="sig-name descname">PyArrayMultiIterObject.iters</code><a class="headerlink" href="#c.PyArrayMultiIterObject.PyArrayMultiIterObject.iters" title="Permalink to this definition">¶</a></dt>
<dd><p>An array of iterator objects that holds the iterators for the
arrays to be broadcast together. On return, the iterators are
adjusted for broadcasting.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="pyarrayneighborhooditer-type-and-pyarrayneighborhooditerobject">
<h3>PyArrayNeighborhoodIter_Type and PyArrayNeighborhoodIterObject<a class="headerlink" href="#pyarrayneighborhooditer-type-and-pyarrayneighborhooditerobject" title="Permalink to this headline">¶</a></h3>
<dl class="var">
<dt id="c.PyArrayNeighborhoodIter_Type">
<code class="sig-name descname">PyArrayNeighborhoodIter_Type</code><a class="headerlink" href="#c.PyArrayNeighborhoodIter_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>This is an iterator object that makes it easy to loop over an
N-dimensional neighborhood.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyArrayNeighborhoodIterObject">
<code class="sig-name descname">PyArrayNeighborhoodIterObject</code><a class="headerlink" href="#c.PyArrayNeighborhoodIterObject" title="Permalink to this definition">¶</a></dt>
<dd><p>The C-structure corresponding to an object of
<a class="reference internal" href="#c.PyArrayNeighborhoodIter_Type" title="PyArrayNeighborhoodIter_Type"><code class="xref c c-data docutils literal notranslate"><span class="pre">PyArrayNeighborhoodIter_Type</span></code></a> is the
<a class="reference internal" href="#c.PyArrayNeighborhoodIterObject" title="PyArrayNeighborhoodIterObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayNeighborhoodIterObject</span></code></a>.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyObject_HEAD</span>
    <span class="kt">int</span> <span class="n">nd_m1</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">index</span><span class="p">,</span> <span class="n">size</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">coordinates</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">]</span>
    <span class="n">npy_intp</span> <span class="n">dims_m1</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_intp</span> <span class="n">strides</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_intp</span> <span class="n">backstrides</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_intp</span> <span class="n">factors</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">PyArrayObject</span> <span class="o">*</span><span class="n">ao</span><span class="p">;</span>
    <span class="kt">char</span> <span class="o">*</span><span class="n">dataptr</span><span class="p">;</span>
    <span class="n">npy_bool</span> <span class="n">contiguous</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">bounds</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">][</span><span class="mi">2</span><span class="p">];</span>
    <span class="n">npy_intp</span> <span class="n">limits</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">][</span><span class="mi">2</span><span class="p">];</span>
    <span class="n">npy_intp</span> <span class="n">limits_sizes</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">npy_iter_get_dataptr_t</span> <span class="n">translate</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">nd</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">dimensions</span><span class="p">[</span><span class="n">NPY_MAXDIMS</span><span class="p">];</span>
    <span class="n">PyArrayIterObject</span><span class="o">*</span> <span class="n">_internal_iter</span><span class="p">;</span>
    <span class="kt">char</span><span class="o">*</span> <span class="n">constant</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">mode</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArrayNeighborhoodIterObject</span><span class="p">;</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="pyarrayflags-type-and-pyarrayflagsobject">
<h3>PyArrayFlags_Type and PyArrayFlagsObject<a class="headerlink" href="#pyarrayflags-type-and-pyarrayflagsobject" title="Permalink to this headline">¶</a></h3>
<dl class="var">
<dt id="c.PyArrayFlags_Type">
<code class="sig-name descname">PyArrayFlags_Type</code><a class="headerlink" href="#c.PyArrayFlags_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>When the flags attribute is retrieved from Python, a special
builtin object of this type is constructed. This special type makes
it easier to work with the different flags by accessing them as
attributes or by accessing them as if the object were a dictionary
with the flag names as entries.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyArrayFlagsObject">
<code class="sig-name descname">PyArrayFlagsObject</code><a class="headerlink" href="#c.PyArrayFlagsObject" title="Permalink to this definition">¶</a></dt>
<dd><div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">PyArrayFlagsObject</span> <span class="p">{</span>
        <span class="n">PyObject_HEAD</span>
        <span class="n">PyObject</span> <span class="o">*</span><span class="n">arr</span><span class="p">;</span>
        <span class="kt">int</span> <span class="n">flags</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArrayFlagsObject</span><span class="p">;</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="scalararraytypes">
<h3>ScalarArrayTypes<a class="headerlink" href="#scalararraytypes" title="Permalink to this headline">¶</a></h3>
<p>There is a Python type for each of the different built-in data types
that can be present in the array Most of these are simple wrappers
around the corresponding data type in C. The C-names for these types
are <code class="xref c c-data docutils literal notranslate"><span class="pre">Py{TYPE}ArrType_Type</span></code> where <code class="docutils literal notranslate"><span class="pre">{TYPE}</span></code> can be</p>
<blockquote>
<div><p><strong>Bool</strong>, <strong>Byte</strong>, <strong>Short</strong>, <strong>Int</strong>, <strong>Long</strong>, <strong>LongLong</strong>,
<strong>UByte</strong>, <strong>UShort</strong>, <strong>UInt</strong>, <strong>ULong</strong>, <strong>ULongLong</strong>,
<strong>Half</strong>, <strong>Float</strong>, <strong>Double</strong>, <strong>LongDouble</strong>, <strong>CFloat</strong>,
<strong>CDouble</strong>, <strong>CLongDouble</strong>, <strong>String</strong>, <strong>Unicode</strong>, <strong>Void</strong>, and
<strong>Object</strong>.</p>
</div></blockquote>
<p>These type names are part of the C-API and can therefore be created in
extension C-code. There is also a <code class="xref c c-data docutils literal notranslate"><span class="pre">PyIntpArrType_Type</span></code> and a
<code class="xref c c-data docutils literal notranslate"><span class="pre">PyUIntpArrType_Type</span></code> that are simple substitutes for one of the
integer types that can hold a pointer on the platform. The structure
of these scalar objects is not exposed to C-code. The function
<a class="reference internal" href="array.html#c.PyArray_ScalarAsCtype" title="PyArray_ScalarAsCtype"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_ScalarAsCtype</span></code></a> (..) can be used to extract the C-type
value from the array scalar and the function <a class="reference internal" href="array.html#c.PyArray_Scalar" title="PyArray_Scalar"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArray_Scalar</span></code></a>
(…) can be used to construct an array scalar from a C-value.</p>
</div>
</div>
<div class="section" id="other-c-structures">
<h2>Other C-Structures<a class="headerlink" href="#other-c-structures" title="Permalink to this headline">¶</a></h2>
<p>A few new C-structures were found to be useful in the development of
NumPy. These C-structures are used in at least one C-API call and are
therefore documented here. The main reason these structures were
defined is to make it easy to use the Python ParseTuple C-API to
convert from Python objects to a useful C-Object.</p>
<div class="section" id="pyarray-dims">
<h3>PyArray_Dims<a class="headerlink" href="#pyarray-dims" title="Permalink to this headline">¶</a></h3>
<dl class="type">
<dt id="c.PyArray_Dims">
<code class="sig-name descname">PyArray_Dims</code><a class="headerlink" href="#c.PyArray_Dims" title="Permalink to this definition">¶</a></dt>
<dd><p>This structure is very useful when shape and/or strides information
is supposed to be interpreted. The structure is:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">npy_intp</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">len</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArray_Dims</span><span class="p">;</span>
</pre></div>
</div>
<p>The members of this structure are</p>
<dl class="member">
<dt id="c.PyArray_Dims.PyArray_Dims.ptr">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArray_Dims.ptr</code><a class="headerlink" href="#c.PyArray_Dims.PyArray_Dims.ptr" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to a list of (<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp"><code class="xref c c-type docutils literal notranslate"><span class="pre">npy_intp</span></code></a>) integers which
usually represent array shape or array strides.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Dims.PyArray_Dims.len">
int <code class="sig-name descname">PyArray_Dims.len</code><a class="headerlink" href="#c.PyArray_Dims.PyArray_Dims.len" title="Permalink to this definition">¶</a></dt>
<dd><p>The length of the list of integers. It is assumed safe to
access <em>ptr</em> [0] to <em>ptr</em> [len-1].</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="pyarray-chunk">
<h3>PyArray_Chunk<a class="headerlink" href="#pyarray-chunk" title="Permalink to this headline">¶</a></h3>
<dl class="type">
<dt id="c.PyArray_Chunk">
<code class="sig-name descname">PyArray_Chunk</code><a class="headerlink" href="#c.PyArray_Chunk" title="Permalink to this definition">¶</a></dt>
<dd><p>This is equivalent to the buffer object structure in Python up to
the ptr member. On 32-bit platforms (<em>i.e.</em> if <a class="reference internal" href="config.html#c.NPY_SIZEOF_INT" title="NPY_SIZEOF_INT"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_SIZEOF_INT</span></code></a>
== <code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_SIZEOF_INTP</span></code>), the len member also matches an equivalent
member of the buffer object. It is useful to represent a generic
single-segment chunk of memory.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="n">PyObject_HEAD</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">base</span><span class="p">;</span>
    <span class="kt">void</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="n">len</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">flags</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArray_Chunk</span><span class="p">;</span>
</pre></div>
</div>
<p>The members are</p>
<dl class="member">
<dt id="c.PyArray_Chunk.PyArray_Chunk.base">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArray_Chunk.base</code><a class="headerlink" href="#c.PyArray_Chunk.PyArray_Chunk.base" title="Permalink to this definition">¶</a></dt>
<dd><p>The Python object this chunk of memory comes from. Needed so that
memory can be accounted for properly.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Chunk.PyArray_Chunk.ptr">
void *<code class="sig-name descname">PyArray_Chunk.ptr</code><a class="headerlink" href="#c.PyArray_Chunk.PyArray_Chunk.ptr" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer to the start of the single-segment chunk of memory.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Chunk.PyArray_Chunk.len">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> <code class="sig-name descname">PyArray_Chunk.len</code><a class="headerlink" href="#c.PyArray_Chunk.PyArray_Chunk.len" title="Permalink to this definition">¶</a></dt>
<dd><p>The length of the segment in bytes.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArray_Chunk.PyArray_Chunk.flags">
int <code class="sig-name descname">PyArray_Chunk.flags</code><a class="headerlink" href="#c.PyArray_Chunk.PyArray_Chunk.flags" title="Permalink to this definition">¶</a></dt>
<dd><p>Any data flags (<em>e.g.</em> <a class="reference internal" href="array.html#c.NPY_ARRAY_WRITEABLE" title="NPY_ARRAY_WRITEABLE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_WRITEABLE</span></code></a> ) that should
be used to interpret the memory.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="pyarrayinterface">
<h3>PyArrayInterface<a class="headerlink" href="#pyarrayinterface" title="Permalink to this headline">¶</a></h3>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../arrays.interface.html#arrays-interface"><span class="std std-ref">The Array Interface</span></a></p>
</div>
<dl class="type">
<dt id="c.PyArrayInterface">
<code class="sig-name descname">PyArrayInterface</code><a class="headerlink" href="#c.PyArrayInterface" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#c.PyArrayInterface" title="PyArrayInterface"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayInterface</span></code></a> structure is defined so that NumPy and
other extension modules can use the rapid array interface
protocol. The <code class="xref py py-obj docutils literal notranslate"><span class="pre">__array_struct__</span></code> method of an object that
supports the rapid array interface protocol should return a
<code class="xref c c-type docutils literal notranslate"><span class="pre">PyCObject</span></code> that contains a pointer to a <a class="reference internal" href="#c.PyArrayInterface" title="PyArrayInterface"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayInterface</span></code></a>
structure with the relevant details of the array. After the new
array is created, the attribute should be <code class="docutils literal notranslate"><span class="pre">DECREF</span></code>’d which will
free the <a class="reference internal" href="#c.PyArrayInterface" title="PyArrayInterface"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayInterface</span></code></a> structure. Remember to <code class="docutils literal notranslate"><span class="pre">INCREF</span></code> the
object (whose <code class="xref py py-obj docutils literal notranslate"><span class="pre">__array_struct__</span></code> attribute was retrieved) and
point the base member of the new <a class="reference internal" href="#c.PyArrayObject" title="PyArrayObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayObject</span></code></a> to this same
object. In this way the memory for the array will be managed
correctly.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span>
    <span class="kt">int</span> <span class="n">two</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">nd</span><span class="p">;</span>
    <span class="kt">char</span> <span class="n">typekind</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">itemsize</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">flags</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="o">*</span><span class="n">shape</span><span class="p">;</span>
    <span class="n">npy_intp</span> <span class="o">*</span><span class="n">strides</span><span class="p">;</span>
    <span class="kt">void</span> <span class="o">*</span><span class="n">data</span><span class="p">;</span>
    <span class="n">PyObject</span> <span class="o">*</span><span class="n">descr</span><span class="p">;</span>
<span class="p">}</span> <span class="n">PyArrayInterface</span><span class="p">;</span>
</pre></div>
</div>
<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.two">
int <code class="sig-name descname">PyArrayInterface.two</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.two" title="Permalink to this definition">¶</a></dt>
<dd><p>the integer 2 as a sanity check.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.nd">
int <code class="sig-name descname">PyArrayInterface.nd</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.nd" title="Permalink to this definition">¶</a></dt>
<dd><p>the number of dimensions in the array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.typekind">
char <code class="sig-name descname">PyArrayInterface.typekind</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.typekind" title="Permalink to this definition">¶</a></dt>
<dd><p>A character indicating what kind of array is present according to the
typestring convention with ‘t’ -&gt; bitfield, ‘b’ -&gt; Boolean, ‘i’ -&gt;
signed integer, ‘u’ -&gt; unsigned integer, ‘f’ -&gt; floating point, ‘c’ -&gt;
complex floating point, ‘O’ -&gt; object, ‘S’ -&gt; (byte-)string, ‘U’ -&gt;
unicode, ‘V’ -&gt; void.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.itemsize">
int <code class="sig-name descname">PyArrayInterface.itemsize</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.itemsize" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of bytes each item in the array requires.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.flags">
int <code class="sig-name descname">PyArrayInterface.flags</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.flags" title="Permalink to this definition">¶</a></dt>
<dd><p>Any of the bits <a class="reference internal" href="array.html#c.NPY_ARRAY_C_CONTIGUOUS" title="NPY_ARRAY_C_CONTIGUOUS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_C_CONTIGUOUS</span></code></a> (1),
<a class="reference internal" href="array.html#c.NPY_ARRAY_F_CONTIGUOUS" title="NPY_ARRAY_F_CONTIGUOUS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_F_CONTIGUOUS</span></code></a> (2), <a class="reference internal" href="array.html#c.NPY_ARRAY_ALIGNED" title="NPY_ARRAY_ALIGNED"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_ALIGNED</span></code></a> (0x100),
<a class="reference internal" href="array.html#c.NPY_ARRAY_NOTSWAPPED" title="NPY_ARRAY_NOTSWAPPED"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_NOTSWAPPED</span></code></a> (0x200), or <a class="reference internal" href="array.html#c.NPY_ARRAY_WRITEABLE" title="NPY_ARRAY_WRITEABLE"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_WRITEABLE</span></code></a>
(0x400) to indicate something about the data. The
<a class="reference internal" href="array.html#c.NPY_ARRAY_ALIGNED" title="NPY_ARRAY_ALIGNED"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_ALIGNED</span></code></a>, <a class="reference internal" href="array.html#c.NPY_ARRAY_C_CONTIGUOUS" title="NPY_ARRAY_C_CONTIGUOUS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_C_CONTIGUOUS</span></code></a>, and
<a class="reference internal" href="array.html#c.NPY_ARRAY_F_CONTIGUOUS" title="NPY_ARRAY_F_CONTIGUOUS"><code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARRAY_F_CONTIGUOUS</span></code></a> flags can actually be determined from
the other parameters. The flag <code class="xref c c-data docutils literal notranslate"><span class="pre">NPY_ARR_HAS_DESCR</span></code>
(0x800) can also be set to indicate to objects consuming the
version 3 array interface that the descr member of the
structure is present (it will be ignored by objects consuming
version 2 of the array interface).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.shape">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayInterface.shape</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.shape" title="Permalink to this definition">¶</a></dt>
<dd><p>An array containing the size of the array in each dimension.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.strides">
<a class="reference internal" href="dtype.html#c.npy_intp" title="npy_intp">npy_intp</a> *<code class="sig-name descname">PyArrayInterface.strides</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.strides" title="Permalink to this definition">¶</a></dt>
<dd><p>An array containing the number of bytes to jump to get to the next
element in each dimension.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.data">
void *<code class="sig-name descname">PyArrayInterface.data</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.data" title="Permalink to this definition">¶</a></dt>
<dd><p>A pointer <em>to</em> the first element of the array.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyArrayInterface.PyArrayInterface.descr">
<a class="reference external" href="https://docs.python.org/dev/c-api/structures.html#c.PyObject" title="(in Python v3.9)">PyObject</a> *<code class="sig-name descname">PyArrayInterface.descr</code><a class="headerlink" href="#c.PyArrayInterface.PyArrayInterface.descr" title="Permalink to this definition">¶</a></dt>
<dd><p>A Python object describing the data-type in more detail (same
as the <em>descr</em> key in <a class="reference internal" href="../arrays.interface.html#__array_interface__" title="__array_interface__"><code class="xref py py-obj docutils literal notranslate"><span class="pre">__array_interface__</span></code></a>). This can be
<code class="docutils literal notranslate"><span class="pre">NULL</span></code> if <em>typekind</em> and <em>itemsize</em> provide enough
information. This field is also ignored unless
<code class="xref c c-data docutils literal notranslate"><span class="pre">ARR_HAS_DESCR</span></code> flag is on in <em>flags</em>.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="internally-used-structures">
<h3>Internally used structures<a class="headerlink" href="#internally-used-structures" title="Permalink to this headline">¶</a></h3>
<p>Internally, the code uses some additional Python objects primarily for
memory management. These types are not accessible directly from
Python, and are not exposed to the C-API. They are included here only
for completeness and assistance in understanding the code.</p>
<dl class="type">
<dt id="c.PyUFuncLoopObject">
<code class="sig-name descname">PyUFuncLoopObject</code><a class="headerlink" href="#c.PyUFuncLoopObject" title="Permalink to this definition">¶</a></dt>
<dd><p>A loose wrapper for a C-structure that contains the information
needed for looping. This is useful if you are trying to understand
the ufunc looping code. The <a class="reference internal" href="#c.PyUFuncLoopObject" title="PyUFuncLoopObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyUFuncLoopObject</span></code></a> is the associated
C-structure. It is defined in the <code class="docutils literal notranslate"><span class="pre">ufuncobject.h</span></code> header.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyUFuncReduceObject">
<code class="sig-name descname">PyUFuncReduceObject</code><a class="headerlink" href="#c.PyUFuncReduceObject" title="Permalink to this definition">¶</a></dt>
<dd><p>A loose wrapper for the C-structure that contains the information
needed for reduce-like methods of ufuncs. This is useful if you are
trying to understand the reduce, accumulate, and reduce-at
code. The <a class="reference internal" href="#c.PyUFuncReduceObject" title="PyUFuncReduceObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyUFuncReduceObject</span></code></a> is the associated C-structure. It
is defined in the <code class="docutils literal notranslate"><span class="pre">ufuncobject.h</span></code> header.</p>
</dd></dl>

<dl class="type">
<dt id="c.PyUFunc_Loop1d">
<code class="sig-name descname">PyUFunc_Loop1d</code><a class="headerlink" href="#c.PyUFunc_Loop1d" title="Permalink to this definition">¶</a></dt>
<dd><p>A simple linked-list of C-structures containing the information needed
to define a 1-d loop for a ufunc for every defined signature of a
user-defined data-type.</p>
</dd></dl>

<dl class="var">
<dt id="c.PyArrayMapIter_Type">
<code class="sig-name descname">PyArrayMapIter_Type</code><a class="headerlink" href="#c.PyArrayMapIter_Type" title="Permalink to this definition">¶</a></dt>
<dd><p>Advanced indexing is handled with this Python type. It is simply a
loose wrapper around the C-structure containing the variables
needed for advanced array indexing. The associated C-structure,
<code class="xref c c-type docutils literal notranslate"><span class="pre">PyArrayMapIterObject</span></code>, is useful if you are trying to
understand the advanced-index mapping code. It is defined in the
<code class="docutils literal notranslate"><span class="pre">arrayobject.h</span></code> header. This type is not exposed to Python and
could be replaced with a C-structure. As a Python type it takes
advantage of reference- counted memory management.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container container-navbar-bottom">
      <div class="spc-navbar">
        
      </div>
    </div>
    <div class="container">
    <div class="footer">
    <div class="row-fluid">
    <ul class="inline pull-left">
      <li>
        &copy; Copyright 2008-2019, The SciPy community.
      </li>
      <li>
      Last updated on Feb 20, 2020.
      </li>
      <li>
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.4.2.
      </li>
    </ul>
    </div>
    </div>
    </div>
  </body>
</html>